咋么说呢...我的代码是真的“暴力”。堪称 屎 世上最长 代妈 代码。见下。
#include<iostream>
using namespace std;
int main()
{
int a,b,c,d,e,f,g,h,i,j,in,x=0;
cin>>in;
for (a=1;a<=3;a++)
{
for (b=1;b<=3;b++)
{
for (c=1;c<=3;c++)
{
for (d=1;d<=3;d++)
{
for (e=1;e<=3;e++)
{
for (f=1;f<=3;f++)
{
for (g=1;g<=3;g++)
{
for(h=1;h<=3;h++)
{
for (i=1;i<=3;i++)
{
for (j=1;j<=3;j++)
{
if (a+b+c+d+e+f+g+h+i+j==in)
{
x++;
}
}
}
}
}
}
}
}
}
}
}
cout<<x<<endl;
for (a=1;a<=3;a++)
{
for (b=1;b<=3;b++)
{
for (c=1;c<=3;c++)
{
for (d=1;d<=3;d++)
{
for (e=1;e<=3;e++)
{
for (f=1;f<=3;f++)
{
for (g=1;g<=3;g++)
{
for(h=1;h<=3;h++)
{
for (i=1;i<=3;i++)
{
for (j=1;j<=3;j++)
{
if (a+b+c+d+e+f+g+h+i+j==in)
{
cout<<a<<" ";
cout<<b<<" ";
cout<<c<<" ";
cout<<d<<" ";
cout<<e<<" ";
cout<<f<<" ";
cout<<g<<" ";
cout<<h<<" ";
cout<<i<<" ";
cout<<j<<endl;
}
}
}
}
}
}
}
}
}
}
}
}
这不长吗? 有没有比这个更LONG的了??
恐怕也没人能看到☛ 记得关注哟!! 点击进入个人主页