我不知道如何计算输入最大数字的次数。请帮忙。如果我将 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;
}