1.用for循环竖排输出1到100:
#include<iostream>
using namespace std; xb==选中看答案
int main(){
for(int i=0;i<=100;i++){
cout<<i<<endl;
}
return 0;
}
2.用for循环计算1到100的和:
#include<iostream>
using namespace std;
int main(){
int a=0;
for(int i=0;i<=100;i++) 选中看答案{
a=a+i;
}
cout<<a;
return 0;
}
3.用for循环计算1到100能被三整除的数的和(用累加器公式):
#include<iostream>
using namespace std;
int main(){
int a=0;
for(int i=0;i<=100;i++){ 选中看答案
if(i%3==0){a=a+i;}
}
cout<<a;
return 0;
}
4.写一个程序,输入一个整数,判断他是机机还是偶偶:
#include<iostream>
using namespace std ; 选中看答案;
int main(){
int a;
cin>>a;
if (a%2==0){cout<<"ouou";}
else {cout<<"jiji";}
return 0;
}
5.编程序,把a,b倒序输出:
#include<iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b 选中看答案;
cout<<b<<a;
return 0;
}
填空:
- C++ 中的流程控制语句包括顺序结构、选择结构和_循环___结构__。
- if 语句的条件表达式必须是__布_尔___类型。
- switch 语句中,每个 case 后面的常量表达式必须是__整形_或_枚举_类型_。
- while 循环的特点是_无限_循环____。
- do-while 循环的特点是__循环_一次
6.输出第二位数组
#include<iostream>
using namespace st 选中看答案d;
int main(){
int a[9]={1,2,3,4};
cout<<a[1];
return 0;
}
3248

被折叠的 条评论
为什么被折叠?



