【NOI OpenJudge】【1.3】编程基础之算术表达式与顺序执行
01: A+B问题
#include<iostream>
using namespace std;
int main(){int a, b;cin>>a>>b;cout<<a+b<<"\n";return 0;
}
02: 计算(a+b)*c的值
#include<iostream>
using namespace std;
int main(){int a, b, c;cin>>a>>b>>c;cout<<(a+b)*c<<"\n";return 0;
}
03:计算(a+b)/c的值
#include<iostream>
using namespace std;
int main(){int a, b, c;cin>>a>>b>>c;cout<<(a+b)/c<<"\n";return 0;
}
04: 带余除法
#include<iostream>
using namespace std;
int main(){int a, b;cin>>a>>b;cout<<a/b<<' '<<a%b<<'\n';return 0;
}
05:计算分数的浮点数值
#include<cstdio>
#include<iostream>
using namespace std;
int main(){double a, b;scanf("%lf%lf",&a,&b);double c = a/b;printf("%.9lf",c);return 0;
}
06:甲流疫情死亡率
#include<cstdio>
#include<iostream>
using namespace std;
int main(){//int a, b;double a, b;scanf("%lf%lf",&a,&b);double c = b/a*100;printf("%.3lf%%",c);return 0;
}
07: 计算多项式的值
#include<cstdio>
#include<iostream>
using namespace std;
int main(){double x, a, b, c, d;scanf("%lf%lf%lf%lf%lf",&x,&a,&b,&c,&d);double ans = x*x*x*a+b*x*x+c*x+d;printf("%.7lf",ans);return 0;
}
08:温度表达转化
#include<cstdio>
#include<iostream>
using namespace std;
int main(){double x;scanf("%lf",&x);double ans = 5*(x-32)/9;printf("%.5lf",ans);return 0;
}
09:与圆相关的计算
#include<cstdio>
#include<iostream>
using namespace std;
const double pi=3.14159;
int main(){double x;scanf("%lf",&x);printf("%.4lf %.4lf %.4lf",x*2,2*pi*x,pi*x*x);return 0;
}
10:计算并联电阻的阻值
#include<cstdio>
#include<iostream>
using namespace std;
int main(){float a, b;scanf("%f%f",&a,&b);float r = 1/(1/a + 1/b);printf("%.2f",r);return 0;
}
11:计算浮点数相除的余数
#include<cstdio>
#include<iostream>
using namespace std;
int main(){double a, b;scanf("%lf%lf",&a,&b);int k = 0;while(a-k*b >= 0){k++;}k--;printf("%g",a-k*b);return 0;
}
12: 计算球的体积
#include<cstdio>
#include<iostream>
using namespace std;
int main(){double x;double pi = 3.14;scanf("%lf",&x);printf("%.2lf",4.0*pi*x*x*x/3);return 0;
}
13:反向输出一个三位数
#include<cstdio>
#include<iostream>
using namespace std;
int cur;
void go(){char ch;if(++cur <= 3){ch = getchar();go();putchar(ch);}
}
int main(){go();return 0;
}
14:大象喝水
#include<cstdio>
#include<iostream>
using namespace std;
int main(){double h, r;double pi = 3.14;scanf("%lf%lf",&h,&r);r*=0.01, h *= 0.01;double v = pi*r*r*h;double ans = 20/(v*1000);printf("%d",(int)(ans-0.0001)/1+1);return 0;
}
15:苹果和虫子
#include<cstdio>
#include<iostream>
using namespace std;
int main(){int n, x, y;cin>>n>>x>>y;int b = (int)((y*1.0/x*1.0-0.001)+1);cout<<n-b<<'\n';return 0;
}
16:计算线段长度
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main(){double x1, y1, x2, y2;scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);printf("%.3lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));return 0;
}
17:计算三角形面积
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main(){double x1, y1, x2, y2, x3, y3;scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);double a = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));double b = sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));double c = sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));double p = (a+b+c)/2;printf("%.2lf\n",sqrt(p*(p-a)*(p-b)*(p-c)));return 0;
}
18:等差数列末项计算
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main(){int a1, a2;cin>>a1>>a2;int d = a2-a1;int n; cin>>n;cout<<a1+(n-1)*d<<'\n';return 0;
}
19:A*B问题
#include<iostream>
using namespace std;
int main(){long long a, b;cin>>a>>b;cout<<a*b<<'\n';return 0;
}
20:计算2的幂
#include<iostream>
using namespace std;
int main(){int n; cin>>n;cout<<(1<<n);return 0;
}
【NOI OpenJudge】【1.3】编程基础之算术表达式与顺序执行相关推荐
- 1.3编程基础之算术表达式与顺序执行 01 A+B问题 (Python3实现)
http://noi.openjudge.cn/ch0103/01/ https://www.luogu.com.cn/problem/P1001 """ P1001 A ...
- 1.3编程基础之算术表达式与顺序执行 01 A+B问题
http://noi.openjudge.cn/ch0103/01/ #include <bits/stdc++.h> using namespace std; int main() {i ...
- 1.3编程基础之算术表达式与顺序执行 02 计算(a+b)*c的值
http://noi.openjudge.cn/ch0103/02/ #include <iostream> #include <bits/stdc++.h> using na ...
- 1.3编程基础之算术表达式与顺序执行 03 计算(a+b) c的值
http://noi.openjudge.cn/ch0103/01/ #include <bits/stdc++.h> using namespace std; int main() {i ...
- 1.3 编程基础之算术表达式与顺序执行 04 带余除法
#include <bits/stdc++.h>using namespace std; int main( void ) {//内存变量 int a,b;int ans;//1.输入 c ...
- 1.3编程基础之算术表达式与顺序执行 05 计算分数的浮点数值
#include <iostream> using namespace std; int main() {int a,b;cin>>a>>b;printf(&quo ...
- 1.3编程基础之算术表达式与顺序执行 06 甲流疫情死亡率
/* 1.3编程基础之算术表达式与顺序执行 06 甲流疫情死亡率 http://noi.openjudge.cn/ch0103/06/ */ #include<iostream> usin ...
- 1.3 编程基础之算术表达式与顺序执行 08 温度表达转化
/* 08:温度表达转化总时间限制: 1000ms 内存限制: 65536kB描述 利用公式 C = 5 * (F-32) / 9 (其中C表示摄氏温度,F表示华氏温度) 进行计算转化.输入 输入一行 ...
- 1.3编程基础之算术表达式与顺序执行(20题)-2022.02.26
1.3编程基础之算术表达式与顺序执行 01 A+B问题 (Python3实现) 1.3编程基础之算术表达式与顺序执行 01 A+B问题 (Python3实现)_青少年趣味编程-CSDN博客 P1001 ...
- 1.3 编程基础之算术表达式与顺序执行(20题)
1.3编程基础之算术表达式与顺序执行 01 A+B问题 (Python3实现) https://blog.csdn.net/dllglvzhenfeng/article/details/1226799 ...
最新文章
- python常用知识点_Python常用知识点
- fckeditor 数据库 取值 显示
- 图像风格迁移_【论文解读】图像风格迁移中的Contextual Loss
- [基础题] 3、设计一个交通工具抽象类,提供抽象方法--驾驶
- 【性能优化】 之10046 事件
- [css] 使用css实现悬浮提示文本
- metro风格后台管理效果
- 资源放送丨《高并发Oracle OLTP系统的故障案例分享》PPT视频
- 基于Jenkins + Tomcat 的安卓客户端可持续化构建及发布下载(loltube.cn)
- NameError: name ‘os‘ is not defined - 解决
- 用友超客:社交化业务就是要化繁为简
- AI时代,运维和测试岗位如何开启第二春?
- (转)PMP的项目管理5大组
- VMware 安装 win7、win10、MAC 和网络模式VMnet0、VMnet1、VMnet8解释
- 合并报表口诀_《中级会计实务》合并报表学不会?据说把他的讲义抄6遍就能过!...
- 大学生免费查题公众号_大学生免费查题公众号?搜题免费公众号?
- 松软科技web课堂:SQLServer之UCASE() 函数
- 做开发3年,字节跳动二面JVM底层被问得哑口无言
- 今日小程序推荐:动态壁纸-你专属壁纸!
- MAC地址冲突,怎么解决?
热门文章
- 奇妙的等式 精妙的证明
- 机器学习基础(四十五)—— 模拟退火(Simulated Annealing)
- Python 数据结构与算法 —— Prim 算法与小顶堆
- 从 Jacobian 矩阵、Hessian 矩阵到 Theano 实现
- Oracle临时库数据数据量过大,Oracle临时表空间过大问题解决
- python从入门到精通 明日科技 电子书-【明日科技+python】百度云下载 - 云盘精灵...
- python画好看的图-Python竟能画这么漂亮的花,帅呆了(代码分享)
- python免费领取视频-最经典Python爬虫全套视频免费领,带你从0开始学爬虫
- php和python-什么是Python和php?Python与PHP有什么区别
- python创意实用案例-9个 Python 实用案例分享