1.3编程基础之算术表达式与顺序执行
刷水题,刷水题
Portal:http://noi.openjudge.cn/ch0103/
01 a+b
02 (a+b)*c
03 (a+b)/c
04 带余除法
05 计算分数的浮点数值
都是看题意能看懂的题
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstring> #include<cstdio> using namespace std; int main() { int a,b; cin>>a>>b; cout<<a+b; return 0; }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstring> #include<cstdio> using namespace std; int main() { int a,b,c; cin>>a>>b>>c; cout<<(a+b)*c; return 0; }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstring> #include<cstdio> using namespace std; int main() { int a,b,c; cin>>a>>b>>c; cout<<(a+b)/c; return 0; }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstring> #include<cstdio> using namespace std; int main() { int a,b; cin>>a>>b; cout<<a/b<<' '<<a%b; return 0; }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstring> #include<cstdio> using namespace std; int main() { double a,b; cin>>a>>b; printf("%.9lf",a/b); return 0; }
06 http://noi.openjudge.cn/ch0103/06/
意外的收获:输出%可以使用printf(“%%”); 233 那么 输出”可以使用printf(“””); 233
07 计算多项式的值
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstring> #include<cstdio> using namespace std; int main() { double a,b,c,d,x; cin>>x>>a>>b>>c>>d; printf("%.7lf",a*x*x*x+b*x*x+c*x+d); return 0; }
其实直接用pow好一点?
过几天搞搞快速多项式除法试试?
08-20
水题,少部分有坑点
直接贴代码
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstring> #include<cstdio> using namespace std; int main() { double f; cin>>f; printf("%.5lf",5*(f-32)/9); return 0; }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstring> #include<cstdio> using namespace std; int main() { double r; cin>>r; printf("%.4lf %.4lf %.4lf",r*2,r*2*3.14159,r*r*3.14159); return 0; }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstring> #include<cstdio> using namespace std; int main() { float r1,r2; cin>>r1>>r2; printf("%.2lf",1/(1/r1+1/r2)); return 0; }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstring> #include<cstdio> using namespace std; int main() { double a,b; cin>>a>>b; int c; c=a/b; printf("%g",a-b*c); return 0; }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstring> #include<cstdio> using namespace std; int main() { double r; cin>>r; printf("%.2lf",3.14*r*r*r*4/3); return 0; }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstring> #include<cstdio> using namespace std; int main() { int n; cin>>n; cout<<n%10<<(n/10)%10<<n/100; return 0; }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstdio> using namespace std; int main() { int v,h,r; cin>>h>>r; v=h*r*r*3.14; cout<<20000/v+1; return 0; }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstdio> #include<cmath> using namespace std; int main() { double xa,ya,xb,yb; cin>>xa>>xb>>ya>>yb; printf("%.3lf",sqrt((xa-ya)*(xa-ya)+(xb-yb)*(xb-yb))); return 0; }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstdio> #include<cmath> using namespace std; int main() { double a,b,c,r; cin>>a>>b>>c; if ((a+b>c)&&(c+b>a)&&(a+c>b)) { r=(a+b+c)/2; printf("%.4lf",sqrt(r*(r-a)*(r-b)*(r-c))); } else cout<<"Data Error"; return 0; }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstdio> #include<cmath> using namespace std; int main() { double x1,x2,x3,y1,y2,y3,a,b,c,r; cin>>x1>>y1>>x2>>y2>>x3>>y3; a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); b=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3)); c=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3)); r=(a+b+c)/2; printf("%.2lf",sqrt(r*(r-a)*(r-b)*(r-c))); return 0; }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstdio> #include<cmath> using namespace std; int main() { int a1,a2,n; cin>>a1>>a2>>n; cout<<a1+(a2-a1)*(n-1); return 0; }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstdio> #include<cmath> using namespace std; int main() { long long a,b; cin>>a>>b; cout<<a*b; return 0; }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstdio> #include<cmath> using namespace std; #define FOR(i,j,k) for(int i=j;i<=k;i++) int main() { long long a,b; cin>>a; b=1; FOR(i,1,a) b=b*2; cout<<b; return 0; }
意外的收获:海伦公式