|
发表于 2019-6-26 21:25:01
|
显示全部楼层
- #include <stdio.h>
- #define LIM 2
- #define SIZE 81
- void menu(void);
- void original(char *str [], int num);
- int main(void)
- {
- char input[LIM][SIZE] = {0};
- char ch;
- int ct = 0;
- printf("Input up to %d lines.\n", LIM);
- while (ct < LIM && gets(input[ct]) != NULL && input[ct][0] != '\n')
- {
- //puts(input[ct]);
- ct++;
- }
- menu();
- while ((ch = getchar()) != 'q')
- {
- switch (ch)
- {
- case 'a':
- original(input,LIM);
- break;
- case 'b':
- case 'c':
- case 'd':
- default:
- printf("q to quit,not other words.\n");
- break;
- }
- menu();
- }
- puts("Bye!");
- getchar();
- return 0;
- }
- void menu(void)
- {
- printf("You have five choices.\n");
- printf("a、Print a list of source strings.\n");
- printf("b、Print strings in order in ASCII.\n");
- printf("c、Print strings in incremental order of length.\n");
- printf("d、Print the string by the length of the first word in the string.\n");
- printf("q、QUIT.\n");
- }
- void original(char *str[], int num)
- {
- int i;
- char (*pt)[SIZE] = str;
- for (i = 0; i < num; i++)
- {
- // pt = str;
- puts(pt[i]);
- }
- }
复制代码 |
|