C++ 信息学奥赛总复习题答案解析(第一章)

第一章 答案解析

填空题

1.cpp
2.main()
3./* */ ,//
4.int a;
5.cout

知识点:

1.C++ 源文件的命名规范

2.C++ 程序的入口函数

3.C++ 注释的两种形式

4.变量声明的语法

5.输出语句的关键字

判断题

1.√
2.×
3.×
4.√
5.√

知识点:

1.C++ 是大小写敏感的语言

2.C++ 程序必须有一个 main 函数

3.注释不会被编译,不影响程序运行速度

4.变量使用前必须声明

5.输出语句中可以使用转义字符如 \n

选择题

1.C
2.A
3.A
4.D
5.C
知识点:

1.标识符的命名规则(以字母或下划线开头,由字母、数字、下划线组成)

2.cout 输出语句的正确用法

3.变量声明可以放在作用域内的任何位置

4.abc 不是 C++ 关键字

5.C++ 语句以分号结束

编程题

1.

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
cout<<"Hello,C++";
return 0;
}

知识点:基本的输入输出语句和程序结构

2.

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
int a=10,b=20;
cout<<a+b;
return 0;
}

知识点:变量声明、赋值和算术运算

3.

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
char s;
cin>>s;
cout<<int(s);    //数据类型转换

return 0;
}

知识点:字符型数据的输入输出及 ASCII 码值的获取

4.

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
int m=0;
for(int i=1;i<=100;i++){
m+=i;
}
cout<<m;


return 0;
}

知识点:for 循环的使用和累加运算

5.

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
cout<<(a+b)/2;

return 0;
}

知识点:浮点型数据的输入输出和平均值计算

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值