听写英语单词的小程序

//有一个问题没有解决:输入begin,若用户输入了char类型的数据就成了个死循环了;

//其他函数没有复制过来,这里只有main函数;

int main()

{
int Chinese(int i, int b = 0); int English(int i, string word, int b = 0); void Grade(int i, float j, int k, int *p);
string word, Key; char Set[10]; int a, b = 0; int i = 0, begin, i_1[2000], k = 0; float  j;//i_1和k是记录答错的单词序号的,j统计分数
cout << "调成英文输入法;运行时输入Key查看答案;输入End以结束程序;" << endl << "Enter the section you want to test:";
cin >> Set;
while (Set[0]<'A' || Set[0]>'Z')
{
++i;
if (i % 3 == 0)
cout << "亲,请输入大写字母A~Z" << endl;
else
cout << "Please input A~Z" << endl;
cout << "Enter the section you want to test:";
cin >> Set;
}
if (Set[0] >= 'B')
{
cout << "The information was not found;" << endl;
cout << "Enter any character to end.";
cin >> word;
return 0;
}/*---------------------------------------------------------------------------------限定输入的选择字母*/
English(0, "Null", (int)Set[0] - 64);
Chinese(0, (int)Set[0] - 64);/*------------------------------------------------输入练习的章节*/
cout << "从第几个单词开始听写好呢? ";
cin >> begin;
while (begin < 1 || begin>300)
{
cout << "请输入1~300之间的数字,亲: ";
cin >> begin;
}
for (i = 1 + begin - 1, j = 0; word != "End"; ++i)/*--------------------------------------------开始运行*/
{
cout << endl;
Chinese(i);
++j;
cin >> word;
if (word == "End")/*---------------------------------------------------------结束(下一道题已经开始了)*/
{
if (i == 1)
{
cout << "蛋疼";
return 0;
}/*-------------------------------------------------------------------------一道题也没做*/
else
{
Grade(i - begin + 1, j - 1, k, i_1);/*--下一道题的开头*/
return 0;
}
}
while (word == "Key")
{
cout << "Tell me your answer first. ";
cin >> word;
if (word == "End")/*-------------------------------------------------------结束(不看答案结束)*/
{
if (i == 1)
{
cout << "真蛋疼";
return 0;
}
else
{
Grade(i - begin + 1, j, k, i_1);/*----看答案时结束*/
return 0;
}


}
}/*--------------------------------------------------------------------------------是不是一上来就看答案并且让看就退了*/
a = English(i, word);/*----------------------------------------------------判断对错,对了返回1,错了返回0*/
if (a == 2)
{
cout << "The program went wrong...";
return 0;
}/*-----------------------------------------------------------一般不会出错的,26个字母*/
while (a != 1)
{
a = 0;
if (b == 0)
{
--j;
i_1[k] = i;
++k;
}/*------------------------------------------------------------------------------统计错题*/
b = 1;
cout << setw(22) << setfill(' ') << "Wrong ! Try again. ";
cin >> word;
if (word == "End")/*-----------------------------------------------------结束*/
{
Grade(i + 1, j, k, i_1);
return 0;
}
else if (word == "Key")/*------------------------------------------------看答案*/
{
cout << "     ";
English(i, word);
cout << endl;
break;
}
else a = English(i, word);/*---------------------------------------------再试一次*/
}
b = 0;/*----------------------------------------------------------------统计错题用的*/
if (a == 1)
cout << setw(35) << setfill(' ') << "Right. Do you want to continue? ";/*-----------------------------------------------------自己做对的*/
else
cout << setw(28) << "Do you want to continue? ";
cin >> word;
}
Grade(i - begin + 1, j, k, i_1);
return 0;
}
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值