赞
踩
目录
【入门1】顺序结构 - 题单 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
- #include<iostream>
- using namespace std;
- int main() {
- cout<<R"( ********
- ************
- ####....#.
- #..###.....##....
- ###.......###### ### ###
- ........... #...# #...#
- ##*####### #.#.# #.#.#
- ####*******###### #.#.# #.#.#
- ...#***.****.*###.... #...# #...#
- ....**********##..... ### ###
- ....**** *****....
- #### ####
- ###### ######
- ##############################################################
- #...#......#.##...#......#.##...#......#.##------------------#
- ###########################################------------------#
- #..#....#....##..#....#....##..#....#....#####################
- ########################################## #----------#
- #.....#......##.....#......##.....#......# #----------#
- ########################################## #----------#
- #.#..#....#..##.#..#....#..##.#..#....#..# #----------#
- ########################################## ############)"<<endl;
- return 0;
- }
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
- #include<iostream>
- #include<ctype.h>
- using namespace std;
- int main(){
- char a;
- cin>>a;
- cout<<char(toupper(a));
- return 0;
- }
- #include<iostream>
- using namespace std;
- int main(){
- char a,b,c,d;
- scanf("%c%c%c.%c",&a,&b,&c,&d);
- printf("%c.%c%c%c",d,c,b,a);
- return 0;
- }
printf("%.3f\n",t/n);
- #include<iostream>
- using namespace std;
- int main(){
- int a,b,c,d;
- cin>>a>>b>>c>>d;
- //在同一天,c一定大于a,只需要判断d和b
- if(d>=b)
- {
- cout<<c-a<<" "<<d-b;
- }
- else
- {
- cout<<c-a-1<<" "<<d+60-b;
- }
- return 0;
- }
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
1/4 int类型, 1.0/4 double类型; 1/4.0 double类型 也得出0.25
表达式的结果为最高类型的结果
- else if(T==13)
- {cout<<(int)(pow(1.0*4/3*pi*1064,1.0/3))<<endl;}
- #include<iostream>
- using namespace std;
- int main(){
- double m,t,s;
- cin>>m>>t>>s;
- if(t==0) //注意当吃一个苹果需要0分钟时,意思是吃苹果很快,最后肯定剩下0个苹果。
- {cout<<"0"<<endl;}
- else if((int)(m-s/t)<=0){
- cout<<"0"<<endl;}
- else{
- cout<<(int)(m-s/t)<<endl;}
- return 0;
- }
n和n-1一定有一个是2的倍数,因此2可以除尽;同理n,n-1,n-2中一定有一个是3的倍数,因此3可以除尽(除掉2只会消除因数2而对3没有影响);同理4也可以除尽
- #include<iostream>
- using namespace std;
- int main(){
- unsigned long long n;
- cin>>n;
- cout<<n * (n-1) / 2 * (n-2) / 3 * (n-3) / 4<<endl;
- return 0;
- }
- #include<iostream>
- #include<math.h>
- using namespace std;
- int main() {
-
- double s, v;
- int hour = 7, min;
- cin >> s >> v;
- int total = ceil(s / v) + 10; //ceil() 向上取整 3/2=2 ceil(s/v) eg:花费3.2分钟,按照4分钟计算
- int totalhour = total / 60;
- min = 60 - total % 60; //70min, 6:50 60-10
- if (total % 60 == 0)
- min = 00;
- while (totalhour--)
- {
- hour--; //如果只写if (hour < 0) 当hour = 24;时 结果中有24:30 hour从7开始设置,前一天同理,
- if (hour < 0 && min != 00)
- hour = 23;
- else if (hour < 0)
- hour = 24;
- }
-
- printf("%02d:%02d",hour ,min );
- return 0;
- }
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。