#include<stdio.h> #include<string.h> int trans(int n,int type){ int sum = 0; int index = 0; if(type==16){ while(n != 0){ sum += n%type; n = n/type; } }else if(type==12){ while(n != 0){ sum += n%type; n = n/type; } } return sum; } void judge(int res[],int n){ int flag = 1; for(int i=1;i<3;i++){ if(res[i]!=res[i-1]){ flag = 0; break; } } if(flag){ printf("%d\n",n); }else{ //do null } } int sum(int n){ int res = 0; res += n%10+n/10%10+n/10/10%10+n/1000; return res; } int main(){ int res[3]; int k; for(int i=2992;i<=9999;i++){ //reset k = 0; //10 res[k++] = sum(i); //12 res[k++] = trans(i,12); //16 res[k++] = trans(i,16); //judge judge(res,i); } return 0; }
Accepted! 但是字符与数字之间的转。。。。我是真的菜!