1 #include <stdio.h> 2 main() 3 { 4 char ch,nch; 5 int count; 6 int k; 7 8 printf("Please input a string with a # in the end\n"); 9 scanf("%c",&ch); 10 while(ch != ‘#‘) 11 { 12 if(ch >= ‘0‘ && ch <= ‘9‘) 13 { 14 15 count = ch-‘0‘+1; 16 scanf("%c",&nch); 17 for(k=0;k<count;k++) 18 printf("%c",nch); 19 } 20 else 21 printf("%c",ch); 22 printf(" "); 23 scanf("%c",&ch); 24 } 25 printf("#\n"); 26 }
时间: 2024-10-13 07:30:07