回复 楼主 ecbtnrt
#include <iostream.h>const int N = 10;
void main()
{
struct
{
int num;
int tim;
}R[N];
int i;
int ar[N];
cout << "please input ten numbers : ";
for(i=0; i<N; i++)
cin >> ar[i];
R[0].num = ar[0];
R[0].tim = 1;
int j;
int t=0,count=0;
int m;
for(i=1; i<N; i++)
{
for(j=0; j<=t; j++)
if(R[j].num ==ar[i])
{ R[j].tim ++;count++;}
if(!count)
{
t++;
R[t].num = ar[i];
R[t].tim = 1;
m = t;
count=0;
}
}
for(i=0; i<=m; i++)
cout << R[i].num << " " << R[i].tim << endl;
}
照着你的思路做的,验证了几个比较小的数,通过了。哈哈