1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 5 int main(int argc, char **argv) 6 { 7 char ibuf[128], *s; 8 int i, n, p; 9 10 if (fgets(&(ibuf[0]), sizeof(ibuf), stdin) == NULL) 11 { 12 return(1); 13 } 14 n = atoi(&(ibuf[0])); 15 16 for (i = 1; i <= n; i++) 17 { 18 if (fgets(&(ibuf[0]), sizeof(ibuf), stdin) == NULL) 19 { 20 break; 21 } 22 s = strchr(&(ibuf[0]), ' '); 23 if (s == NULL) 24 { 25 break; 26 } 27 *s++ = '\0'; 28 p = atoi(&(ibuf[0])); 29 printf("%d ", i); 30 for (; *s != '\0' && *s != '\n' && *s != '\r'; s++) 31 { 32 p--; 33 if (p == 0) 34 { 35 continue; 36 } 37 putc(*s, stdout); 38 } 39 putc('\n', stdout); 40 } 41 42 return(0); 43 }