首师大附中科创教育平台我的刷题记录(这次给大家刷多一点,31--40题吧)
仅供同学们参考,禁止抄袭!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#include<iostream> using namespace std; int main() { int n; cin>>n; if(n%4==0&&n%100!=0||n%400==0) cout<<"yes"<<endl; else cout<<"no"<<endl; return 0; }
闰年判断
#include<iostream> using namespace std; int main() { int n; cin>>n; if(n<101&&n>84) cout<<"A"<<endl; if(n<85&&n>74) cout<<"B"<<endl; if(n<75&&n>59) cout<<"C"<<endl; if(n<60) cout<<"D"<<endl; return 0; }
分数等级转换
#include<iostream> using namespace std; int main() { int n; cin>>n; if(n==1) cout<<"星期一"<<endl; if(n==2) cout<<"星期二"<<endl; if(n==3) cout<<"星期三"<<endl; if(n==4) cout<<"星期四"<<endl; if(n==5) cout<<"星期五"<<endl; if(n==6) cout<<"星期六"<<endl; if(n==7) cout<<"星期日"<<endl; if(n!=1&&n!=2&&n!=3&&n!=4&&n!=5&&n!=6&&n!=7) cout<<"输入有误"<<endl; return 0; }
数字和星期转换
#include<iostream> using namespace std; int main() { int n; cin>>n; if(n<=3)cout<<"10"; if(n>3&&n<=15)cout<<(n-3)*2+10; if(n>15)cout<<(n-15)*2.4+34; return 0; }
打车费的计算
#include<iostream> using namespace std; int main() { double n,a; cin>> n; if(n<=100)cout<<n<<endl; if(n>100&&n<=300)cout<<9*n/10<<endl; a=(n-300)*8/10; if(n>300)cout<<300*9/10+a<<endl; return 0; }
购书款的计算
#include<iostream> using namespace std; int main() { double n; cin>> n; if(n<300)cout<<n<<endl; if(n>=300&&n<500)cout<<n*9/10<<endl; if(n>=500&&n<1000)cout<<8*n/10<<endl; if(n>=1000)cout<<n-300<<endl; return 0; }
商场促销
#include<iostream> #include<cmath> using namespace std; int main() { double a,b,c,m,x1,x2; cin>>a>>b>>c; m=b*b-4*a*c; if(m>0) { x1=(-b-sqrt(m))/(2*a); x2=(-b+sqrt(m))/(2*a); cout<<x1<<" "<<x2; } else { if(m<0)cout<<"No"; else cout<<-b/(2*a); } return 0; }
解一元二次方程
#include <cstdlib> #include <iostream> using namespace std; int main(int argc, char *argv[]) { long int y,m,d,a; char x; cin>>y>>x>>m>>x>>d; if(y%4==0&&y%100!=0||y%400==0) a=29; else a=28; if(m>1) d=d+31; if(m>2) d=d+a; if(m>3) d=d+31; if(m>4) d=d+30; if(m>5) d=d+31; if(m>6) d=d+30; if(m>7) d=d+31; if(m>8) d=d+31; if(m>9) d=d+30; if(m>10) d=d+31; if(m>11) d=d+30; cout<<d<<endl; //system("PAUSE"); return EXIT_SUCCESS; }
算一算是一年中的第几天
#include<iostream> using namespace std; int main() { int a1,a2,a3,a4,a5,max,min,ans; cin>>a1>>a2>>a3>>a4>>a5; if(a1>a2) max=a1; else max=a2; if(a3>max) max=a3; if(a4>max) max=a4; if(a5>max) max=a5; if(a1<a2) min=a1; else min=a2; if(a3<min) min=a3; if(a4<min) min=a4; if(a5<min) min=a5; ans=min*max; cout<<ans; }
求最小数与最大数的乘积
#include<iostream> using namespace std; int main() { int a,b,c,e; char d; cin>>a>>d>>b>>d>>c; e=3600*a+60*b+c; cout<<e<<endl; cin>>e; a=e/3600; e=e%3600; b=e/60; e=e%60; c=e; if(a<10)cout<<"0"; cout<<a<<d; if(b<10)cout<<"0"; cout<<b<<d; if(c<10)cout<<"0"; cout<<c; }
时间转换
时间: 2024-10-07 04:27:27