编写一个程序,确定一个正整数是否完美。您的程序识别排列和组合足球比分
并显示1到10,000之间的所有完美数字。 编写一个从用户读取整数的程序。如果用户输入的值小于2,则您的程序应显示相应的错误消息。否则,你的程序应该
显示屏,可以相乘的素数计算N,每行出现
的一个因素。例如:
0-0, 1-0, 2-0, 2-1
0-0, 0-1, 1-1, 2-1
{
int m, n;
cout<<"Enter the finals scores of both teams";
cout<<"\nenter the score for team m :";
cin>>m;
cout<<"Enter the score for team n :";
cin>>n;
if (m < 0 && n < 0){
cout<<"score can't be negative";
cout<<"\nenter the score for team m :";
cin>>m;
cout<<"Enter the score for team n :";
cin>>n;
}
else{
int k=0;
if (n==0){
for (int j = 0; j <= m; j++){
for (k; k <= n; k+=1){
cout<<j<<"-"<<k<<",\t";
}
k--;
}
}
else if(m==1 && n==1){
int i=0;
int k=0;
for (int j = 0; j <= m; j++){
for (k; k <= n; k+=1){
cout<<j<<"-"<<k<<",\t";
}
k--;
}
cout<<endl<<endl;
for (int j = 0; j <= n; j++){
for (i; i <= m; i+=1){
cout<<i<<"-"<<j<<",\t";
}
i--;
}
}
else {
int i=0;
int k=0;
for (int j = 0; j <= m; j++){
for (k; k <= n; k+=1){
cout<<j<<"-"<<k<<",\t";
}
k--;
}
cout<<endl<<endl;
for (int j = 0; j <= n; j++){
for (i; i <= m; i++){
cout<<i<<"-"<<j<<",\t";
}
i--;
}
}
}
}
首先,如果'(M <0 &&Ñ<0){'应该是'如果(M <0 ||Ñ<0){' 。 – DimChtz
你并不需要所有'if/else if/else',你需要的只是2个嵌套for循环,用于'm','n'的任意组合。 – DimChtz
@DanialKhan你的调试器实际上被破坏了吗? –