标签:include return src http std 情况 generator \n clu
code:
1 #include<stdio.h> 2 3 //count the number of the digit. 4 int count_digits(int a) 5 { 6 int count = 0; 7 while(a) 8 { 9 a /= 10; 10 count++; 11 } 12 return count; 13 } 14 15 //the function to be used to judge the digit 16 /* 17 yes : return the generator 18 no : retur 0. 19 */ 20 int judgement(int a) 21 { 22 int i = 0; 23 int count = count_digits(a); 24 for(i = a - count*9; i < a; i++) 25 { 26 int sum = i; 27 int temp = i; 28 while(temp > 0) 29 { 30 sum += temp%10; 31 temp /= 10; 32 } 33 if(sum == a) return i; 34 } 35 return 0; 36 } 37 38 int main() 39 { 40 int T, a; 41 scanf("%d",&T); 42 int i = 0; 43 for(; i < T; i++) 44 { 45 scanf("%d",&a); 46 printf("%d\n",judgement(a)); 47 } 48 return 0; 49 50 }
ps:
标签:include return src http std 情况 generator \n clu
原文地址:https://www.cnblogs.com/dreamworldclark/p/9407313.html