|
编写在37个说中选出7个数组合,问选出7个相同的数的选发有几种并分别列出来.
程序如下:我用的是枚举但是有好多错误我不知道为什么 有谁能看看吗?
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
enum num{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37};
num pri;
int a,b,c,d,e,f,g,n=0,loop;
for(a=01;a<=37;a++)
for(b=01;b<=37;b++)
if(a!=b)
for(c=01;c<=37;c++)
if(c!=a&&c!=b)
for(d=01;d<=37;d++)
if(d!=a&&d!=b&&c!=d)
for(e=01;e<=37;e++)
if(e!=a&&e!=b&&e!=c&&e!=d&&)
for(f=01;f<=37;f++)
if(f!=a&&f!=b&&f!=c&&f!=d&&f!=e)
for(g=01;g<=37;g++)
if(g!=a&&g!=b&&g!=c&&g!=d&&g!=e&&g!=f)
{n+=1;
cout<<setw(5)<<n;
for(loop=1;loop<=7;loop++)
{switch(loop)
{case 1: pri=num(a);break;
case 2: pri=num(b);break;
case 3: pri=num(c);break;
case 4: pri=num(d);break;
case 5: pri=num(e);break;
case 6: pri=num(f);break;
case 7: pri=num(g);break;
default: break;
}
switch(pri)
{case 1:cout<<setw(8)<<1;break;
case 2:cout<<setw(8)<<2;break;
case 3:cout<<setw(8)<<3;break;
case 4:cout<<setw(8)<<4;break;
case 5:cout<<setw(8)<<5;break;
case 6:cout<<setw(8)<<6;break;
case 7:cout<<setw(8)<<7;break;
case 8:cout<<setw(8)<<8;break;
case 9:cout<<setw(8)<<9;break;
case 10:cout<<setw(8)<<10;break;
case 11:cout<<setw(8)<<11;break;
case 12:cout<<setw(8)<<12;break;
case 13:cout<<setw(8)<<13;break;
case 14:cout<<setw(8)<<14;break;
case 15:cout<<setw(8)<<15;break;
case 16:cout<<setw(8)<<16;break;
case 17:cout<<setw(8)<<17;break;
case 18:cout<<setw(8)<<18;break;
case 19:cout<<setw(8)<<19;break;
case 20:cout<<setw(8)<<20;break;
case 21:cout<<setw(8)<<21;break;
case 22:cout<<setw(8)<<22;break;
case 23:cout<<setw(8)<<23;break;
case 24:cout<<setw(8)<<24;break;
case 25:cout<<setw(8)<<25;break;
case 26:cout<<setw(8)<<26;break;
case 27:cout<<setw(8)<<27;break;
case 28:cout<<setw(8)<<28;break;
case 29:cout<<setw(8)<<29;break;
case 30:cout<<setw(8)<<30;break;
case 31:cout<<setw(8)<<31;break;
case 32:cout<<setw(8)<<32;break;
case 33:cout<<setw(8)<<33;break;
case 34:cout<<setw(8)<<34;break;
case 35:cout<<setw(8)<<35;break;
case 36:cout<<setw(8)<<36;break;
case 37:cout<<setw(8)<<37;break;
default: break;
}
}
cout<<endl;
}
}
cout<<"total:"<<n<<endl;
return 0;
}
提示错误如下:
附件: 只有本站会员才能下载或查看附件,请您 登录 或 注册 |
|