-6
我应该输入10个整数并打印最大和最小的数字,以及最重复的数字。最重复的号码有时打印正确的号码,有时不打印。任何想法为什么?我的代码有什么问题? (C++数组)
#include <iostream>
using namespace std;
int main()
{
int i,x,n[10],count[10],max=0,min=999999,mc=0;
cout<<"Please Enter 10 Integers\n";
for(i=0;i<10;i++){
cin>>n[i];
if(n[i]<min)
min=n[i];
if(n[i]>max)
max=n[i];
for(x=0;x==i;x++){
if(n[i]==n[x])
count[x]++;
}
}
for(i=0;i<10;i++){
if(count[i]>mc)
mc=n[i];
}
cout<<"The Max is "<<max<<endl<<"The Min is "<<min<<endl<<"The most repeated number is "<<mc<<endl;
return 0;
}
难道是你在写隐形码吗? – systemcpro
除非您通过编辑图像中的像素来编写代码,否则请将其作为* text *插入,因为这就是它的原因。 –
对不起,这是我在网站上的第一个问题,我在编写它时遇到了麻烦。现在很清楚 –