# 2019程序设计基础第二次月考（BY） 解题报告

cww970329 edited 8 月，4 周前

#### A

for 循环小练习，把

“男女序号每轮递加，达到最大值重新初始化”

#include<stdio.h>
int main()
{
int a,b,round;
scanf("%d %d %d",&a,&b,&round);
int m=0,n=0,i;
for(i=0;i<round;i++)
{
m=m+1;
n=n+1;
if(m>a) m=1;
if(n>b) n=1;
printf("%d %d\n",m,n);

}
return 0;
}


First Blood: 齐海昕, HarisonChih

#### B

#include <stdio.h>

int main() {
int n;
scanf("%d", &n);
while(n--) {
int hour, minute, sceond;
scanf("%d:%d:%d", &hour, &minute, &second);
int t0 = 8*60*60;
int t = ((hour*60)+minute)*60+second;
int d = t0 - t;
if(d<10*60) {
printf("You are late!\n");
} else if(d<15*60){
printf("Hurry up!\n");
} else {
printf("You are living a healthy life!\n");
}
}
return 0;
}


• 如果时间差小于10分钟，迟到了("You are late!")

• 如果时间差大于等于10分钟，小于15分钟，只能跑步去，而且来不及买早饭("Hurry up!")

• 如果时间差大于等于15分钟，小于20分钟，有两种选择

• 跑步去，顺便买个早饭("You are living a healthy life!")
• 走路去，不买早饭了("You should have been early!")

• 如果时间差大于等于20分钟，迟到了("You are late!")

—By Yoshino-s

Frist Blood: 崔晨洋, yoshino-s

#### C

#include<bits/stdc++.h>
using namespace std;
main(){
string s;
int flag = 1;
while (cin >> s){
for(int i = 0; i < s.size(); i++){
if(s[i]=='.'||s[i]=='\''||s[i]=='?'||s[i]==','||(s[i]>='0'&& s[i]<='9')) {
s[i] = '\0';
break;
}
}
if (s == "is" || s == "are" || s == "in" || s == "and"){
cout<<"English"<<endl;
return 0;
}
if (s.size() > 6) flag = 0;
}
if (flag) cout << "Chinese" << endl;
else cout << "Japanese" << endl;
}


First Blood: 周佳馨, 5033一生推

#### D

#include <stdio.h>

int main() {
int t, i, j, ans = 0;
scanf("%d", &t);
for(i = 1; i <= t; i++){
int n;
scanf("%d", &n);
int a;
ans = 0;
for (j = 0; j < n; j++){
scanf("%d", &a);
if (a <= 10) ans++;
}
printf("%d\n", ans);
}
return 0;
}


First Blood: 周孜为, 滋味233

#### 总结

B的题解

7点又分为三部分：45分之前，45分后50分之前，50分之后，分别对应”You are living a healthy life!”、“Hurry up!”和”You are late!”。

#include<iostream>

using namespace std;

int main(){

int n;

cin>>n;

while(n--) {

int hour, minute, second;

scanf("%d:%d:%d", &hour, &minute, &second);

if      (hour<7){

cout<<"You are living a healthy life!"<<endl;

}

else if (hour>7){

cout<<"You are late!"<<endl;

}

else            {

if      (minute>=0&&minute<=45)
cout<<"You are living a healthy life!"<<endl;
else if (minute>45&&minute<50)
cout<<"Hurry up!"<<endl;
else if (minute==50&&second==0)
cout<<"Hurry up!"<<endl;
else
cout<<"You are late!"<<endl;

}
}

return 0;

}


#include <stdio.h>
#include <string.h>

int main()
{
char word[40];
while(~scanf("%s",&word))
{
if(strcmp(word,"guo")==0)
{
printf("Chinese");
return 0;
}
if(strcmp(word,"chuan")==0)
{
printf("Chinese");
return 0;
}
if(strcmp(word,"zhong")==0)
{
printf("Chinese");
return 0;
}
if(strcmp(word,"yun")==0)
{
printf("Chinese");
return 0;
}

if(strcmp(word,"kishi")==0)
{
printf("Japanese");
return 0;
}
if(strcmp(word,"mashi")==0)
{
printf("Japanese");
return 0;
}
if(strcmp(word,"sanka")==0)
{
printf("Japanese");
return 0;
}
if(strcmp(word,"ga")==0)
{
printf("Japanese");
return 0;
}

}
printf("English");
return 0;
}


——zcz

C题用cpp是怎么输出的，为什么点回车没输出