标签:统计 ++ gets max class alt pre namespace dig
第二次:
#include <bits/stdc++.h> #include <math.h> #include <cstring> #include <cstdio> using namespace std; const int MAX_LEN = 100005; //const int MAX_D = 31; int main(){ char str[MAX_LEN]; int result[10] ={0}; //gets(str); cin>>str; int len = strlen(str); for(int i =0;i<len;++i){ result[str[i]-‘0‘]++; } for(int i = 0;i<10;++i){ if(result[i]!=0){ printf("%d:%d\n",i,result[i]); } } system("pause"); return 0; }
第一次:
#include <bits/stdc++.h> #include<math.h> using namespace std; const int MAX_LEN = 100005; //const int MAX_D = 31; int main(){ int n; cin>>n; int digit = 0; int temp[10]={0}; if(n == 0){ printf("0:1\n"); } while(n != 0){ int d = n % 10; temp[d]++; n = n/10; } for(int i=0;i<=9;++i){ if(temp[i]!=0){ printf("%d:%d\n",i,temp[i]); } } system("pause"); return 0; }
标签:统计 ++ gets max class alt pre namespace dig
原文地址:https://www.cnblogs.com/JasonPeng1/p/12129611.html