一天小彭在上英语课时思考要花多少天才能把六级词汇背完,打算在没有早八的时候背诵20个有早八时就明天背,于是用最近学习的c语言来解答自己的问题
#include <stdio.h>
int main()
{
int vocabulary = 4000;
int day = 0;
int today;
for(today = 1;today <= 7;today++)
{
if(today == 2 || today == 3 || today == 4)
{
day++;
printf("今天无早八不背单词\n");
printf("已用日数:%d\n",day);
}
else if(today == 1 || today == 5 || today == 6)
{
printf("今天无早八背二十个单词\n");
vocabulary = vocabulary + 20;
day++;
printf("已用日数:%d\n",day);
printf("以背诵单词:%d\n", vocabulary);
}
else if(today == 7)
{
day++;
printf("今天无早八不背单词\n");
vocabulary = vocabulary + 20;
printf("以背诵单词:%d\n", vocabulary);
printf("已用日数:%d\n",day);
today = 0;
}
if(vocabulary == 9000)
{
printf("\"你已经可以考六级了!\"");
break;
}
}
return 0;
}