中国电子学会2023年03月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;
}

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

#include<iostream>
using namespace std;

int main()
{
	int a,b,S;
	cin>>a>>b;
	S=a*b;
	cout<<S;
	return 0;
}

在这里插入图片描述
解析: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;
}

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

#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;
}

在这里插入图片描述
解析: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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ChenWenKen

你的鼓励是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值