当前位置:   article > 正文

中国电子学会2023年03月C++语言等级考试试卷一级真题及(参考答案)_电子学会c++考试真题

电子学会c++考试真题

在这里插入图片描述
解析:这题主要考察变量定义,输入输出,循环的应用。

#include<iostream>
using namespace std;

int main()
{
	char c;
	cin>>c;
	for(int i=0;i<=2;i++){
		for(int j=0;j<=3;j++){
			cout<<c;
		}
		cout<<endl;
	}
	return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

在这里插入图片描述
在这里插入图片描述
解析:主要考察算式应用

#include<iostream>
using namespace std;

int main()
{
	int a,b,S;
	cin>>a>>b;
	S=a*b;
	cout<<S;
	return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

在这里插入图片描述
解析:if循环的实际应用。

#include<iostream>
using namespace std;

int main()
{
	int score;
	cin>>score;
	if(score>=90 && score<=100){
		cout<<"A";
	}else if(score>=77 && score<=89){
		cout<<"B";
	}else if(score>=67 && score<=76){
		cout<<"C";
	}else if(score>=60 && score<=66){
		cout<<"D";
	}else{
		cout<<"E";
	}
	return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

在这里插入图片描述
解析:会使用循环镶嵌,定义标识

#include<iostream>
using namespace std;

int main()
{
	int a,num,min=-1;
	cin>>a;
	for(int i=0;i<a;i++){
		cin>>num;
		if(min==-1){
			min = num;
			cout<<'N'<<endl;
		}else{
			if(min>num){
				min = num;
				cout<<'N'<<endl;
			}else{
				cout<<'Y'<<endl;
			}
		}
	}
	return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

在这里插入图片描述
解析:while无限循环的应用,灵活应用整除取余。

#include<iostream>
using namespace std;

int main()
{
	int num,a,b,c,d;
	cin>>num;
	while(true){
		num+=1;
		a = num/1000;
		b = num%1000/100;
		c = num%100/10;
		d = num%10;
		if(a+b+c+d==20){
			cout<<num;
			break;
		}
	}
	return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/169640
推荐阅读
相关标签
  

闽ICP备14008679号