生活随笔
收集整理的這篇文章主要介紹了
C语言----单词听写小程序
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
假期實在玩夠了,于是就寫了個小代碼,希望能激勵到自己背單詞
主要功能,先輸入自己要考的單詞,然后他就會顯示漢語,以達到聽寫英語的作用
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <malloc.h>
# define N 2typedef struct linklist
{char word1
[100]; char word2
[100]; struct linklist
*pNext
;
}Word
;
void CreateLinkist(Word
* head
)
{Word
*p
;p
= head
;for(int i
=1; i
<=N
; i
++){Word
*s
;s
= (Word
*)malloc(sizeof(Word
));printf("請輸入第 %d 個單詞\n",i
);scanf("%s", s
->word1
);scanf("%s", s
->word2
);p
->pNext
= s
;s
->pNext
= NULL;p
= s
;}printf("\n");}
void PrintfLinklist(Word
*head
)
{Word
*node
;node
= head
->pNext
;while(node
!= NULL){printf("%s\n", node
->word1
);printf("%s\n", node
->word2
);node
= node
->pNext
;}}int main()
{Word
*head
;head
= (Word
*)malloc(sizeof(Word
*));head
->pNext
= NULL;char s
[100];int flag
= 0;CreateLinkist(head
);system("cls");Word
*node
;node
= head
->pNext
;while(node
!= NULL){printf("%s", node
->word2
);scanf("%s", s
);if(strcmp(s
, node
->word1
) != 0){flag
= 1;}if(flag
== 0)node
= node
->pNext
;elseflag
= 0;}printf("\n");printf("*****************************\n");printf("*今日單詞已背完,繼續加油呀!*\n");printf("*****************************\n");}
總結
以上是生活随笔為你收集整理的C语言----单词听写小程序的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。