排序1
#include<iostream> using namespace std; int main() { int a,b,c,d,e,x; cin>>a>>b>>c>>d>>e; if(a<b) { x=a; a=b; b=x; } if(a<c) { x=a; a=c; c=x; } if(a<d) { x=a; a=d; d=x; } if(a<e) { x=a; a=e; e=x; } if(b<c) { x=b; b=c; c=x; } if(b<d) { x=b; b=d; d=x; } if(b<e) { x=b; b=e; e=x; } if(c<d) { x=c; c=d; d=x; } if(c<e) { x=c; c=e; e=x; } if(d<e) { x=d; d=e; e=x; } cout<<e<<‘ ‘<<d<<‘ ‘<<c<<‘ ‘<<b<<‘ ‘<<a<<endl; return 0 ; }
排序2
#include<iostream> #include<iomanip> #include<cmath> #include<cstdio> using namespace std; int main() { freopen("distance.in","r",stdin); freopen("distance.out","w",stdout); cout<<setiosflags(ios::fixed)<<setprecision(2); int x1,y1,x2,y2; double a,b; cin>>x1>>y1>>x2>>y2; a=sqrt( ( (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2) )*1.0); cout<<a<<endl; b=(x1-x2)+(y1-y2); {if(b>=0) cout<<b<<endl; else cout<<-b<<endl;} return 0; }
求距离1
#include<iostream> #include<cstdio> #include<cmath> #include<iomanip> using namespace std; int main() { freopen("distance.in","r",stdin); freopen("distance.out","w",stdout); cout<<setiosflags(ios::fixed)<<setprecision(2); int xx1,xx2,yy1,yy2; cin>>xx1>>yy1>>xx2>>yy2; double c,d,e,f; c=sqrt(1.0*(xx1-xx2)*(xx1-xx2)+1.0*(yy1-yy2)*(yy1-yy2)); if(xx1<xx2) d=xx2-xx1; else d=xx1-xx2; if(yy1<yy2) e=yy2-yy1; else e=yy1-yy2; f=d+e; cout<<c<<endl<<f<<endl; return 0; }
求距离2
#include<iostream> #include<cstdio> using namespace std; int main() { freopen("task.in","r",stdin); freopen("task.out","w",stdout); int a,b; cin>>a>>b; if(a+b<10) cout<<"water"<<endl; if(a+b>=10&&a>b) cout<<"tree"<<endl; if(a+b>=10&&a<=b) cout<<"tea"<<endl; return 0; }
任务分配
#include<iostream> #include<cstdio> using namespace std; int main() { freopen("snail.in","r",stdin); freopen("snail.out","w",stdout); int D,a,b,x=0;//x是计数器 cin>>D>>a>>b; if(a<=b&&D>a) cout<<"bye bye"<<endl; else { for(;;) { x++; D-=a; if(D<=0) break; D+=b; } cout<<x<<endl; } return 0; }
蜗牛出井
这次考试是班里的后几名,怎么说呢,很难受,觉得打击挺大的。但是通过这四天的学习,我觉得我还是有很大的收获的。我的一道0分题是因为文件输入输出的格式错误,这种错误很低级,以后需要注意一定要避免这种错误,这种错误是最让人后悔的。还有一道20分的题是因为自己没有吧各种情况考虑周全,以后编程的时候一定要先把这道题当作一道数学题先把它做出来,然后再用编程语言写在计算机上。
时间: 2024-10-12 23:47:17