This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
class:os2014f:hw1 [2014/09/11 09:56] mhshin |
class:os2014f:hw1 [2025/10/13 12:45] (current) |
||
|---|---|---|---|
| Line 8: | Line 8: | ||
| <code> | <code> | ||
| - | char *word_list[10][20]; | + | #include <stdio.h> |
| + | #include <stdlib.h> | ||
| + | #include <random> | ||
| + | |||
| + | int main( void ) | ||
| + | { | ||
| + | char word_list[10][20]; | ||
| int word_cnt; | int word_cnt; | ||
| printf("How many words do you want?:"); | printf("How many words do you want?:"); | ||
| - | scanf("%d", word_cnt); | + | scanf("%d", &word_cnt); |
| printf("Please enter %d words\n", word_cnt); | printf("Please enter %d words\n", word_cnt); | ||
| for( int i=0; i<word_cnt; i++) { | for( int i=0; i<word_cnt; i++) { | ||
| - | printf("Enter %d th word:", i); | + | printf("Enter %d th word:", i+1); |
| scanf("%s", word_list[i]); | scanf("%s", word_list[i]); | ||
| } | } | ||
| + | printf("## Word List ##\n"); | ||
| + | | ||
| + | for( int i=0; i<10; i++) { | ||
| + | printf("The %d th word is %s\n", i+1, word_list[i]); | ||
| + | } | ||
| + | |||
| + | system("pause"); | ||
| + | | ||
| + | return 0; | ||
| + | } | ||
| </code> | </code> | ||