版本比较
单词听写
正文
增加 62 行删除 24 行
76 行未改动777879808181828384858687888990869192939495969297989910010110210310410010110510610710310410510610710810911011111211311411511611711811912011611712112212311912412512612712812412913013112712813213313413513613013113213313413513713813813913914014114214314414514614714814915015115215315415515615715815916016116216316416516616716819 行未改动18818919019119219319419519619719819920020120220320420520620720820921021121221376 行未改动 return 0;}```
#### Windows版本(终端输入版本):#### Windows版本(终端输入版本)(更新颜色):
```cpp#include<bits/stdc++.h>using namespace std;#define RESET "\033[0m"#define RED "\033[31m"#define GREEN "\033[32m"#define YELLOW "\033[33m"#define BOLD "\033[1m"int n ;int n , con ;struct node{ string kind ; string word ; string chinese ; int val ;}a[1000005];}a[1000005] , wrong[100005] ;bool cmp( node a , node b ){ if( a.val != b.val ) return ( rand()%10000 > 5000 ? a.val < b.val : a.val > b.val ) ; else return rand()%20000 > 1013 ;}signed main(){ srand(time(0)); while( 1 ) {// while( 1 )// { cin >> n ; if( n < 40 || n > 300 ) { cout << "Make sure you have press the number of the words in the front of the file and the number can not bigger than 300 or less than 40.\n" ; return 0; }// if( n < 40 || n > 300 )// {// cout << "Make sure you have press the number of the words in the front of the file and the number can not bigger than 300 or less than 40.\n" ;// return 0;// } for( int i = 1 ; i <= n ; i ++ ) { cin >> a[i].kind ; cin >> a[i].word ; cin >> a[i].chinese ; a[i].val = rand()%10000 ; } sort( a+1 , a+n+1 , cmp ) ; break ; }// break ;// } string check ; cout << "Please key in \"ok\" to strat the test,or key in \"not prepared\" to stop.\n" ; cout << YELLOW << "Please key in \"ok\" to strat the test,or key in \"not prepared\" to stop.\n" << RESET ; while( cin >> check ) { if( check == "not prepared" ) return 0; if( check == "ok" ) break ; cout << "Please key in \"ok\" to strat the test\n" ; cout << YELLOW << "Please key in \"ok\" to strat the test\n" << RESET ; } do{ cout << "\n\n\n\n\n\n\n\n\n\nNow I am going to give you 10 English words in total.You need to give me your ans,than I will give you the correct answer in the given file.You needs to compare them in yourself.\n" ; for( int i = 1 ; i <= min( n , 10 ) ; i ++ ) int num = 0 ; con = 0 ; cout << "Now I am going to give you 40 Chinese meaning of a word in total.You need to key in the English word,than I will compare them and give you the result.\n" ; for( int i = min( n+1 , 1 ) ; i <= min( n , 40 ) ; i ++ ) { cout << i << ". " << a[i].kind << " " << a[i].word << "\n" ; while( cin >> check ) {cout << a[i].chinese << "\n" ;break ;} } cout << "Now I am going to give you 30 Chinese meaning of a word in total.You need to key in the English word,than I will compare them and give you the result.\n" ; for( int i = min( n+1 , 11 ) ; i <= min( 2*n , 40 ) ; i ++ ) { cout << i << ". " << a[i].kind << " " << a[i].chinese << "\n" ; cin >> check ; if( check == a[i].word ) cout << "Answer right.\n" ; else cout << "Wrong answer!The correct answer is:" << a[i].word << ".\n" ; if( check == a[i].word ) cout << GREEN << "Answer right.\n" << RESET , num ++ ; else { wrong[++con] = a[i] ; cout << RED << "Wrong answer!" << RESET << "The correct answer is:" << BOLD << a[i].word << ".\n" << RESET ; } } cout << YELLOW << "In this part,you got " << num << "/" << min( n , 40 ) << " points\n" << RESET ; if( con ) { cout << YELLOW << "Your answers were wrong on these words:\n" << RESET ; for( int i = 1 ; i <= con ; i ++ ) cout << wrong[i].kind << " " << BOLD << wrong[i].word << RESET << " " << wrong[i].chinese << "\n" ; } else { cout << GREEN << "All the answers are correct.Congratulation!\n" << RESET ; } cout << "If you need to have a test again,please key in \"again\" to continue.\n" ; cin >> check ; if( check != "again" ) return 0; for( int i = 1 ; i <= n ; i ++ ) a[i].val = rand()%30000 ; sort( a+1 , a+n+1 , cmp ) ; }while(1) ; return 0;}
```
### 词库文本:
19 行未改动
[word list 17](https://www.luogu.com.cn/paste/tg305dru)
[word list 18](https://www.luogu.com.cn/paste/sheia1sn)
[word list 21](https://www.luogu.com.cn/paste/e23bckb5)
[word list 22](https://www.luogu.com.cn/paste/y3mx88im)
[word list 23](https://www.luogu.com.cn/paste/o4zccnbu)
[word list 24](https://www.luogu.com.cn/paste/2bpb3hby)
[word list 25](https://www.luogu.com.cn/paste/zdahl4kw)
[word list 26](https://www.luogu.com.cn/paste/j0llzkb9)
[word list 27](https://www.luogu.com.cn/paste/eg63r05h)
[word list 30](https://www.luogu.com.cn/paste/att5w0f6)
[word list 31](https://www.luogu.com.cn/paste/nhdvze20)
[word list 33](https://www.luogu.com.cn/paste/hl8mmifl)
[word list 34](https://www.luogu.com.cn/paste/7whglp1q)