信奥一本通 顺序结构程序设计

第一节 运算符和表达式

2064
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << b << ' '  << a << endl;
	
	return 0;
}
2065
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << a + b + c << endl;
	
	return 0;
}
2066
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	printf("%.2f\n", n - m * 0.8);
	
	return 0;
}
1066
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << a + b << endl;
	
	return 0;
}
1007
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a + b) * c << endl;
	
	return 0;
}
1008
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a + b) / c << endl;
	
	return 0;
}
1009
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << a / b << ' ' << a % b << endl;
	
	return 0;
}
1010
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	printf("%.9f\n", a * 1.0 / b);
	
	return 0;
}

第二节 常量和变量

2067
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	double r, pi = 3.14159;
	cin >> r;
	
	double d = 2 * r;
	double l = 2 * pi * r;
	double s = pi * r * r;
	
	printf("%.4f %.4f %.4f\n", d, l, s);
	
	return 0;
}
2068
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int x, y;
	cin >> x >> y;
	
	cout << (4 * x - y) / 2 << ' ' << (y - 2 * x) / 2 << endl;
	
	return 0;
}
1011
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	printf("%.3lf%%\n", 100.0*b/a);
	
	return 0;
}
1012
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	double x, a, b, c, d;
	scanf("%lf %lf %lf %lf %lf", &x, &a, &b, &c, &d);
	printf("%.7lf", a*x*x*x + b*x*x + c*x + d);
	
	return 0;
}
1013
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	double f, c;
	cin >> f;
	c = 5 * (f - 32) / 9;
	printf("%.5f\n", c);
	
	return 0;
}
1014
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	double r, pi = 3.14159;
	cin >> r;
	
	double d = 2 * r;
	double l = 2 * pi * r;
	double s = pi * r * r;
	
	printf("%.4f %.4f %.4f\n", d, l, s);
	
	return 0;
}
1015
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	double r1, r2, r;
	cin >> r1 >> r2;
	
	r = 1 / (1/r1 + 1/r2);
	
	printf("%.2f", r);
	
	return 0;
}

第三节 标准数据类型

1414
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << a * 0.2 + b * 0.3 + c * 0.5;
	
	return 0;
}
1016
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int a;
	short b;
	
	cout << sizeof(a) << ' ' << sizeof(b) << endl;
		
	return 0;
}
1017
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	float a;
	double b;
	
	cout << sizeof(a) << ' ' << sizeof(b) << endl;
		
	return 0;
}
1018
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	bool a;
	char b;
	
	cout << sizeof(a) << ' ' << sizeof(b) << endl;
		
	return 0;
}
1019
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	float a;
	cin >> a;
	cout << int(a) << endl;
		
	return 0;
}
1020
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	char ch;
	cin >> ch;
	cout << int(ch) << endl;
		
	return 0;
}
1021
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int a;
	cin >> a;
	cout << char(a) << endl;
		
	return 0;
}
1022
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int a;
	bool b;
	int c;
	
	cin >> a;
	b = a;
	c = b;
	cout << c << endl;
		
	return 0;
}
1023
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	cout << sizeof("Hello, World!") << endl;
		
	return 0;
}

第四节 数据输入输出

2069
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	
	b += a/3, e += a/3, a/=3;
	c += b/3, a += b/3, b/=3;
	d += c/3, b += c/3, c/=3;
	e += d/3, c += d/3, d/=3;
	a += e/3, d += e/3, e/=3;
	
	printf("%5d%5d%5d%5d%5d\n", a, b, c, d, e);
	
	return 0;
}
1024
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	float a;
	cin >> a;
	printf("%.3f\n", a);
	
	return 0;
}
1025
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	double a;
	cin >> a;
	printf("%.12f\n", a);
	
	return 0;
}
1026
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	char a;
	int b;
	float c;	
	double d;	
	
	cin >> a >> b >> c >> d;
	
	cout << a << ' ';
	cout << b << ' ';
	printf("%f ", c); 
	printf("%f ", d);
	
	return 0;
}
1027
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	double a;
	
	scanf("%lf", &a);
	printf("%f\n%.5f\n%e\n%g\n", a, a, a, a);
	
	return 0;
}
1028
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	char c;
	
	scanf("%c", &c);
	printf("  %c\n", c);
	printf(" %c%c%c\n", c, c, c);
	printf("%c%c%c%c%c\n", c, c, c, c, c);
	printf(" %c%c%c\n", c, c, c);
	printf("  %c\n", c);
	
	return 0;
}

第五节 顺序结构实例

2070
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int n, num = 0;
	cin >> n;
	
	num = num * 10 + n % 10;
	n /= 10;
	
	num = num * 10 + n % 10;
	n /= 10;
	
	num = num * 10 + n % 10;
	n /= 10;
	
	cout << num << endl;
	
	return 0;
}
2071
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int x, y;
	cin >> x >> y;
	
	printf("%.4f\n", (87.0*x + 85.0*y) / (x + y));
	
	return 0;
}
2072
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	double x = 9.6 * 6;
	
	x = x - (x - 9.4 * 5) - (x - 9.8 * 5);
	
	printf("%5.2f\n", x / 4);
	
	return 0;
}
2073
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	double a, b, c;
	cin >> a >> b >> c;
	
	double p = (a + b + c) / 2;
	double s = sqrt(p * (p-a) * (p-b) * (p-c));
	
	printf("%.3f\n", s);
	
	return 0;
}
1029
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	double a, b, ans;
	int k;
	cin >> a >> b;
	k = a/ b;
	ans = a- b * k;
	cout << ans << endl;
	
	return 0;
}
1030
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	double r; 
	double v; 
	double pi = 3.14;
	
	cin >> r;
	v = 4.0 / 3 * pi * r * r * r;
	
	printf("%.2f\n", v); 
	
	return 0;
}
1031
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int n;
	cin >> n;
	
	int g = n % 10; 
	int s = n / 10 % 10;
	int b = n / 100; 
	
	cout << g << s << b << endl;
	
	return 0;
}
1032
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	int h, r;
	cin >> h >> r;
	double v = 3.14 * r * r * h;
	
	cout << ceil(20000/v) << endl;
	
	return 0;
}
1033
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	double xa, ya, xb, yb;
	cin >> xa >> ya;
	cin >> xb >> yb;
	
	double len = 0;
	len += (xa-xb) * (xa-xb);
	len += (ya-yb) * (ya-yb);
	len = sqrt(len);
	
	printf("%.3f\n", len);
	
	return 0;
}
1034
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	double x1,y1,x2,y2,x3,y3;
	cin >> x1 >> y1;
	cin >> x2 >> y2;
	cin >> x3 >> y3;

	double a = sqrt( pow((x1-x2),2) + pow((y1-y2),2) );
	double b = sqrt( pow((x2-x3),2) + pow((y2-y3),2) );
	double c = sqrt( pow((x3-x1),2) + pow((y3-y1),2) );

	double p = 0.5 * (a + b + c);
	
	double s = sqrt(p*(p-a)*(p-b)*(p-c));
	
	printf("%.2f\n", s);
	
	return 0;
}
1035
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int a1, a2, n;
	
	scanf("%d %d %d", &a1, &a2, &n);
	printf("%d\n", a1 + (a2 - a1) * (n - 1));
	
	return 0;
}
1036
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	long long a, b, ans;
	cin >> a >> b;
	
	ans = a * b;
	
	cout << ans << endl;
	
	return 0;
}
1037
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	int n, ans;
	cin >> n;
	
	ans = pow(2, n);
	cout << ans << endl;
	
	return 0;
}
1038
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	int n, x, y;
	cin >> n >> x >> y;
	
	int left = n - ceil(1.0*y/x);
	cout << max(left, 0) << endl;
	
	return 0;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值