NOIP(一)
1 #include <iostream>
2 using namespace std;
3 double sum(double a,double b,double c){
4 double V = 0;
5 //得到abc的值
6 scanf("%lf%lf%lf",&a,&b,&c);
7 //计算梯形的面积
8 V = ((a + b) * c) / 2;
9 return V;
10 }
11 int main(){
12 printf("%0.8lf",sum(15.12,25.25,10.18));
13 return 0;
14 }
1 #include <iostream>
2 using namespace std;
3 //牛吃草 。草场够15有牛吃20天,20头牛吃10天。
4 //问:每天新增的草量够多少头牛吃一天?
5 int n(){
6 int s1,s2,s3;
7 s1 = 15 * 20;
8 s2 = 20 * 10;
9 s3 = (s1 - s2)/(20 - 10);
10
11 return s3;
12 }
13 int main(){
14 cout << n();
15 return 0;
16 }
1 #include <iostream>
2 using namespace std;
3
4 int n(){
5 // 设1亿人一年消耗的总资源位单位1
6 //
7 // x亿人 a年
8 // 110 * 90 = 9900
9 //
10 // x > y && a < b && ax < by < 10000
11 //
12 // y亿人 b年
13 // 90 * 210 = 18900
14 //
15 // (18900 - 9900) y亿人b年消耗的总资源比x亿人a年消耗的总资源的增量
16 // (18900 - 9900) / (210 - 90) 表示每年内增量资源总和
17 //
18 int x,y,a,b;
19 cin >> x >> a >> y >> b;
20 double z = (y*b - a*x) / (b - a);
21 printf("%.2lf",z);
22 return 0;
23
24 temp空瓶子
25 a酱油 b醋
26 double temp;
27 int a;
28 int b;
29 溢出
30 int temp; 2ml
31 double a; 2.5ml
32 double b; 2.5ml
33 temp = a
34 a = b
35 b = temp
36
37 顶针
38 读好书,书好读
39 }
40
41 int main(){
42 n();
43 return 0;
44 }
1 #include <iostream>
2 using namespace std;
3 double n(){
4 double r = 0,h;
5 bool k;
6 cout << sizeof(k) << endl;
7 double pi = 3.1415926;
8 scanf("%lf%lf",&r,&h);
9 return 2 * (pi * r * r) + (2 * pi * r) * h;
10 //
11 // if (a > b):
12 // return a + b;
13 // else:
14 // return a - b;
15 // 三目运算
16 // a > b ? a + b : a - b;
17
18 2 1 0
19 2 1 0
20 2 1 0
21 }
22
23 int main(){
24 double cmj = n();
25 printf("%0.3lf",cmj);
26 return 0;
27 }
1 #include <iostream>
2 using namespace std;
3 //华氏、摄氏温度转化
4 int main(){
5 // 5 * (f - 32) / 9 = 5/9 * (f - 32)
6 double f,c;
7 scanf("%lf",&f);
8 c = 5 * (f - 32) / 9;
9 printf("%.5lf",c);
10 return 0;
11 }
1 #include <iostream>
2 using namespace std;
3 //大小写字母转化
4 int main(){
5 char c1 = 'd';
6 char c2 = 'D';
7 c1 = c1 - 32;
8 c2 = c2 + 32;
9 cout << c1 << " " << c2 << endl;
10 int c;
11 scanf("%d",&c);
12 i = int
13 c = char
14 s = string
15 f = float
16
17 return 0;
18 }
1 #include <iostream>
2 using namespace std;
3 //分糖:5位小朋友分糖。
4 //每位小朋友的糖均分成3份,分给邻近的小朋友。
5 //求: 原来每位小朋友有多少糖果
6 int main(){
7 int a,b,c,d,e;
8 cin >> a >> b >> c >> d >> e;
9 //1号 13
10 a = a/3;
11 b = b + a;
12 e = e + a;
13 //2
14 b = b / 3;
15 a = a + b;
16 c = c + b;
17 //3
18 c = c / 3;
19 b = b + c;
20 d = d + c;
21 //4
22 d = d / 3;
23 c = c + d;
24 e = e + d;
25 //5
26 e = e /3;
27 d = d + e;
28 a = a + e;
29 cout << a << " " << b << " "<< c << " " << d << " "<< e;
30 return 0;
31 }
1 #include <iostream>
2 using namespace std;
3 int main(){
4 //五位小朋友分糖,从a开始,除自已以外每个人分完糖以后都得到原来的2倍。
5 //当第五位小朋友分完糖以后,每人手上都有32块糖。
6 //求原来每位小朋友手上有多少糖
7
8 // a分糖,bcde都获取到*2
9 // b分糖,acde*2
10 // c分糖,abde*2
11 // d分糖,abce*2
12 // e分糖,32 32 32 32 32
13
14 // 不管当前谁分糖,都要执行5次
15 // 最后一次大家的糖一样,逆推
16
17 // 输出:81 41 21 11 6
18 // a b c d e
19 // 81 41 21 11 6
20 // 2 82 42 22 12 增量: 79,剩余:2
21 // 4 4 84 44 24 增量: 75,剩余:9
22 // 8 8 8 88 48
23 // 16 16 16 16 96
24 // 32 32 32 32 32
25
26 int f[5] = {32,32,32,32,32};
27 //确定递推的关系式为倒推
28 for(int i = 4;i >= 0;i--){
29 //循环5次
30 for(int j = 0;j < 5;j++){
31 //确定分糖的关系式--当前正在分糖的人不是他本人
32 if(i != j){
33 f[j] = f[j] / 2;//倒着分,每个人得到的当是原来的1/2
34 f[i] = f[i] + f[j];//i这个人一共有的糖果是原来手上的+分到的
35 }
36 }
37 }
38 for(int i = 0;i < 5;i++){
39 cout << f[i] << " ";
40 }
41
42 return 0;
43 }
1 #include <iostream>
2 #include <cmath>
3 using namespace std;
4 //个十百倒掉
5 int main(){
6 // 任何一个数对10取余得到的都是个位数 (a > 10)
7 double a,b,c,p,s;
8 scanf("%lf%lf%lf",&a,&b,&c);
9 p = (a + b + c)/2;
10 s = sqrt(p*(p-a)*(p-b)*(p-c));
11 printf("%.3lf",s);
12 return 0;
13 }
代码虐我千百遍,我待代码如初恋!--gogo-BUG!
吃过符号的亏,上过大小写的当!--gogo-DEBUG!

浙公网安备 33010602011771号