编写程序,读取整数,找出它们中的最大数并计算该数的出现次数。假设输入是以0结束的。如果输入为3525550,那么程序找出最大数是5,而5出现的次数是4。
测试用例
3525550
The largest number is 5
The occurrence count of the largest number is 4
编写程序,读取整数,找出它们中的最大数并计算该数的出现次数。假设输入是以0结束的。如果输入为3525550,那么程序找出最大数是5,而5出现的次数是4。
测试用例
3525550
The largest number is 5
The occurrence count of the largest number is 4
int s[10]{},n=0,d=0;
scanf("%d",&n);
while(n)++s[n%10],n/=10;
while(++n)if(s[n]>s[d])d=n;
printf("The largest number is %d\nThe occurrence count of the largest number is %d\n", d, s[d]);