https://www.luogu.com.cn/training/100#problems

B2002 Hello,World!

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(void)
  4. {
  5. printf("Hello,World!");
  6. return 0;
  7. }

B2025 输出字符菱形

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(void)
  4. {
  5. for(int i=1;i<=3;i++)
  6. {
  7. for(int j=1;j<=3-i;j++)
  8. cout<<" ";
  9. for(int j=1;j<=i*2-1;j++)
  10. cout<<"*";
  11. puts("");
  12. }
  13. for(int i=2;i>=1;i--)
  14. {
  15. for(int j=1;j<=2-i+1;j++) cout<<" ";
  16. for(int j=1;j<=i*2-1;j++)
  17. cout<<"*";
  18. puts("");
  19. }
  20. return 0;
  21. }

P1000 超级玛丽游戏

  1. #include<stdio.h>
  2. int main() {
  3. printf(
  4. " ********\n"
  5. " ************\n"
  6. " ####....#.\n"
  7. " #..###.....##....\n"
  8. " ###.......###### ### ###\n"
  9. " ........... #...# #...#\n"
  10. " ##*####### #.#.# #.#.#\n"
  11. " ####*******###### #.#.# #.#.#\n"
  12. " ...#***.****.*###.... #...# #...#\n"
  13. " ....**********##..... ### ###\n"
  14. " ....**** *****....\n"
  15. " #### ####\n"
  16. " ###### ######\n"
  17. "##############################################################\n"
  18. "#...#......#.##...#......#.##...#......#.##------------------#\n"
  19. "###########################################------------------#\n"
  20. "#..#....#....##..#....#....##..#....#....#####################\n"
  21. "########################################## #----------#\n"
  22. "#.....#......##.....#......##.....#......# #----------#\n"
  23. "########################################## #----------#\n"
  24. "#.#..#....#..##.#..#....#..##.#..#....#..# #----------#\n"
  25. "########################################## ############\n"
  26. );
  27. return 0;
  28. }

P1001 A+B Problem

  1. #include<stdio.h>
  2. int main(void)
  3. {
  4. int a,b;
  5. scanf("%d %d",&a,&b);
  6. printf("%d",a+b);
  7. return 0;
  8. }

B2005 字符三角形

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(void)
  4. {
  5. string c; cin>>c;
  6. for(int i=1;i<=3;i++)
  7. {
  8. for(int j=1;j<=3-i;j++) cout<<" ";
  9. for(int j=1;j<=i*2-1;j++) cout<<c;
  10. puts("");
  11. }
  12. return 0;
  13. }

P5703 【深基2.例5】苹果采购

  1. #include<stdio.h>
  2. int main(void)
  3. {
  4. unsigned long a,b;
  5. scanf("%lu %lu",&a,&b);
  6. printf("%lu",a*b);
  7. return 0;
  8. }

P5704 【深基2.例6】字母转换

  1. #include<stdio.h>
  2. int main(void)
  3. {
  4. char a;
  5. a=getchar();
  6. printf("%c\n",a-32);
  7. return 0;
  8. }

P5705 【深基2.例7】数字反转

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(void)
  4. {
  5. string s; cin>>s;
  6. reverse(s.begin(),s.end());
  7. cout<<s;
  8. return 0;
  9. }

P5706 【深基2.例8】再分肥宅水

  1. #include<stdio.h>
  2. int main(void)
  3. {
  4. double V;
  5. int n;
  6. scanf("%lf %d",&V,&n);
  7. printf("%.3lf\n%d",V/n,n*2);
  8. return 0;
  9. }

P5708 【深基2.习2】三角形面积

  1. #include<stdio.h>
  2. #include<math.h>
  3. int main(void)
  4. {
  5. double a,b,c;
  6. double sum;
  7. scanf("%lf %lf %lf",&a,&b,&c);
  8. sum=(a+b+c)/2.0;
  9. sum=sum*(sum-a)*(sum-b)*(sum-c);
  10. printf("%.1lf",sqrt(sum));
  11. return 0;
  12. }

P5707 【深基2.例12】上学迟到

  1. #include<cstdio>
  2. #include<iostream>
  3. #include<cmath>
  4. using namespace std;
  5. int a1=8*60;
  6. int a2=24*60;
  7. int main(void)
  8. {
  9. int s,v; cin>>s>>v;
  10. int t;
  11. if(s%v==0) t=s/v;
  12. else t=s/v+1;
  13. int temp=a1-t-10;
  14. if(temp>=0)
  15. {
  16. printf("%02d:%02d\n",temp/60,temp%60);
  17. }
  18. else
  19. {
  20. temp=a2+temp;
  21. printf("%02d:%02d\n",temp/60,temp%60);
  22. }
  23. return 0;
  24. }

B2029 大象喝水

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define pi 3.1415926
  4. int main(void)
  5. {
  6. double h,r; cin>>h>>r;
  7. int ans=ceil(20*1000/(h*pi*r*r));
  8. cout<<ans<<endl;
  9. return 0;
  10. }

P1425 小鱼的游泳时间

  1. #include<cstdio>
  2. #include<iostream>
  3. using namespace std;
  4. int main(void)
  5. {
  6. int a,b,c,d; cin>>a>>b>>c>>d;
  7. int sum1=a*60+b;
  8. int sum2=c*60+d;
  9. printf("%d %d\n",(sum2-sum1)/60,(sum2-sum1)%60);
  10. return 0;
  11. }

P1421 小玉买文具

  1. #include<cstdio>
  2. #include<iostream>
  3. using namespace std;
  4. int main(void)
  5. {
  6. int a=19;
  7. int s1,s2; cin>>s1>>s2;
  8. cout<<(s1*10+s2)/a<<endl;
  9. return 0;
  10. }

P3954 [NOIP2017 普及组] 成绩

  1. #include<stdio.h>
  2. int main(void)
  3. {
  4. int A, B,C;
  5. int sum=0;
  6. scanf("%d %d %d",&A,&B,&C);
  7. sum=A*0.2+B*0.3+C*0.5;
  8. printf("%d",sum);
  9. return 0;
  10. }