0
我无法弄清楚如何统计最大次数输入的次数。请帮忙。如果我初始化s为0,它不会计算第一个数字,如果它是最高的。统计发生最大次数的次数
#include <stdio.h>
int main (void)
{
int times=0,n,m,i,max;
printf("How many numbers(n) you going to enter:\n");
scanf("%d",&n);
printf("Enter the numbers:\n");
scanf("%d",&m);
max=m;
for(i=1;i<=n;i++)
{
scanf("%d",&m);
if(m==max)
times++;
if(m>max)
max=m;
}
printf("The Largest Number is %d and was entered %d times",max , times);
return 1;
}
@DavidSchwartz:对不起,我错过了'最大= M'一部分。 – Ryan
OH YA!多谢你们。猜测我的大脑有点模糊,想到任何逻辑。 –