本篇包含:
1、1001-这是一道签到题
2、1002-排列式子
3、1003-小飞机
4、1004-学姐的"Helloworld!"
5、1005-乘法表
6、1006-KiKi学程序设计基础
7、1007-疫情死亡率
8、1008-爱因斯坦的名言
9、1009-字符串输出1.0
10、1010-牛牛学说话之-整数
11、1011-牛牛学说话之-浮点数
12、1012-牛牛学加法
13、1013-牛牛学除法
14、1014-牛牛学取余
15、1015-浮点除法
本篇包含考点:
1、不带输入的输出
2、带输入的输出
3、标准格式输出
4、转义字符
5、加减乘除取余运算
1001-这是一道签到题
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
string s[7]={"zhe","shi","yi","dao","qian","dao","ti"};
for(int i=0;i<7;i++){
cout<<s[i]<<endl;
}
}
解析:
注:不包含输入的简单输出
笔者采用了字符串数组的形式,再用 for 循环输出
若有读者用 printf 或 cout 直接输出,亦可
1002-排列式
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
string s[9]={"4396 = 28 x 157","5346 = 18 x 297","5346 = 27 x 198","5796 = 12 x 483","5796 = 42 x 138","6952 = 4 x 1738","7254 = 39 x 186","7632 = 48 x 159","7852 = 4 x 1963"};
for(int i=0;i<9;i++){
cout<<s[i]<<endl;
}
}
解析:
同1001
1003-小飞机
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
printf(" ** \n");
printf(" ** \n");
printf("************\n");
printf("************\n");
printf(" * * \n");
printf(" * * ");
}
解析:
交了四发才过,惨烈地贡献了错误率
第一发,飞机尾部没分开,以为和头部一样是连在一起(x)
第二发,机翼数量数错,12数为10(x)
第三发,后知后觉地发现,飞机用的是 * ,而笔者用的是 x ,啊对对对,就是xyz的x
1004-学姐的"Helloworld!"
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
cout<<"Helo word!";
}
解析:
简单输出
1005-乘法表
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
cout<<"1*1= 1"<<endl;
cout<<"1*2= 2 2*2= 4"<<endl;
cout<<"1*3= 3 2*3= 6 3*3= 9"<<endl;
cout<<"1*4= 4 2*4= 8 3*4=12 4*4=16"<<endl;
cout<<"1*5= 5 2*5=10 3*5=15 4*5=20 5*5=25"<<endl;
cout<<"1*6= 6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36"<<endl;
cout<<"1*7= 7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49"<<endl;
cout<<"1*8= 8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64"<<endl;
cout<<"1*9= 9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81"<<endl;
}
解析:
有兴趣的读者朋友们可以用 for 循环实现,也是一样的
1006-KiKi学程序设计基础
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
cout<<"printf(\"Hello world!\\n\");"<<endl;
cout<<"cout << \"Hello world!\" << endl;";
}
解析:
这里最主要的一个点是:转义字符 '\'
什么是转义字符呢?读者朋友们可以自己将参考代码,然后随意删减 \ 就能明白了
1007-疫情死亡率
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
double n,m;
cin>>n>>m;
float a=m*100/n;
printf("%.3f",a);
cout<<"%";
}
解析:
读入数据,标准化格式输出,
%:占位符
.3:小数点后三位
f:浮点类型数
1008-爱因斯坦的名言
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
cout<<"\"Genius is 1% inspiration and 99% perspiration.\"";
}
解析:
同1006
1009-字符串输出1.0
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
for(int i=0;i<3;i++){
cout<<"Welcome to ACM / ICPC!"<<endl;
}
}
解析:
可以用 for 循环,也可以写三次的 printf 或者 cout
1010-牛牛学说话之-整数
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
cout<<s;
}
解析:
这题用字符串会类型会更方便,以免爆 int
1011-牛牛学说话之-浮点数
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
double a;
cin>>a;
printf("%.3f",a);
}
解析:
同1007
1012-牛牛学加法
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
cout<<a+b;
}
解析:
简单的输入输出
1013-牛牛学除法
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
cout<<a/b;
}
解析:
同1012
1014-牛牛学取余
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
cout<<a%b;
}
解析:
同1012
1015-浮点除法
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
double a,b;
cin>>a>>b;
printf("%.3f",a/b);
}
解析:
同1012和1006
如果大家有不懂的,或者文章有何不正,都欢迎评论留言进行讨论或者私信作者