1 条题解
-
0
C :
#include <stdio.h> #include <math.h> #include <stdlib.h> #include <time.h> int main() { // freopen("in","r",stdin); // freopen("out","w",stdout); int c1,c2,c3,max,i; long n; while(scanf("%ld",&n)!=EOF) { c1 = c2 = c3 = 0; while (n) { i=n%10; switch(i) { case 1: c1++;break; case 2: c2++;break; case 3: c3++; } n/= 10; } max=c1; if(max<c2) max=c2; if(max<c3) max=c3; printf("%d %d %d %d\n",c1,c2,c3,max); } return 0; }
C++ :
#include<stdio.h> main() { int a[10],i,n,m,l,max; long b; while(scanf("%d",&b)!=EOF) { n=0;l=0;m=0;i=0; while(b!=0) { a[i]=(b%10); b=b/10; i++; } for(i=0;i<10;i++) { if(a[i]==1) n+=1; else if(a[i]==2) m+=1; else if(a[i]==3) l+=1; } if(n>m) max=n; else max=m; if(max<l) max=l; printf("%d %d %d %d\n",n,m,l,max); } }
- 1
信息
- ID
- 276
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者