整数的千位分隔
Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)
C-sources:
1 #include<stdio.h> 2 int main() 3 { 4 int number; 5 unsigned int ThreeBefore,ThreeAfter; 6 printf("Please input the value of number: "); 7 scanf("%d",&number); 8 9 unsigned int *in=NULL; 10 in=(int*)malloc(number*sizeof(int)); 11 12 int i; 13 for(i=0;i<number;i++) 14 { 15 scanf("%u",&in[i]); 16 } 17 18 for(i=0;i<number;i++) 19 { 20 if(in[i]<=999) 21 printf("%u ",in[i]); 22 else 23 { 24 ThreeBefore=in[i]/1000; 25 ThreeAfter=in[i]%1000; 26 printf("%u,%u ",ThreeBefore,ThreeAfter); 27 } 28 } 29 return 0; 30 }