#include<iostream>usingnamespace std;intmain(){int n; cin>>n;int ok =0;if(n%3==0){
cout<<3<<' '; ok =1;}if(n%5==0){
cout<<5<<' '; ok =1;}if(n%7==0){
cout<<7<<' '; ok =1;}if(!ok)cout<<"n";return0;}
10:有一门课不及格的学生
#include<iostream>usingnamespace std;intmain(){int a, b;
cin>>a>>b;if(a<60&& b>=60|| b<60&&a>=60){
cout<<1;}else cout<<0;return0;}
#include<cstdio>#include<iostream>usingnamespace std;intmain(){int w;char s;
cin>>w>>s;int ans =8;if(s=='y')ans +=5;if(w<=1000){
cout<<ans<<'
';return0;}else{
w -=1000;
ans +=((w-1)/500+1)*4;
cout<<ans;}return0;}
15:最大数输出
#include<iostream>#include<cmath>usingnamespace std;intmain(){int a, b, c;
cin>>a>>b>>c;
cout<<(max(a,max(b,c)))<<'
';return0;}
#include<iostream>#include<cmath>usingnamespace std;intmain(){int a, b;char op;
cin>>a>>b>>op;if(op =='+')cout<<(a+b);elseif(op=='-')cout<<(a-b);elseif(op=='*')cout<<(a*b);elseif(op=='/'){if(b==0)cout<<"Divided by zero!";else cout<<(a/b);}else cout<<"Invalid operator!";return0;}
20:求一元二次方程的根
#include<cstdio>#include<iostream>#include<cmath>usingnamespace std;intmain(){float a, b, c, x;
cin>>a>>b>>c;if(b*b==4*a*c){printf("x1=x2=%.5f",(-b+sqrt(b*b-4*a*c))/(2*a));}elseif(b*b>4*a*c){printf("x1=%.5f;x2=%.5f",(-b+sqrt(b*b-4*a*c))/(2*a),(-b-sqrt(b*b-4*a*c))/(2*a));}else{
x =(-b/(2*a));if(x==-0.00000)x=0;printf("x1=%.5f+%.5fi;x2=%.5f-%.5fi",x,(sqrt(4*a*c-b*b)/(2*a)),x,(sqrt(4*a*c-b*b)/(2*a)));}return0;}
21:苹果和虫子2
#include<cstdio>#include<iostream>#include<cmath>usingnamespace std;intmain(){int n, x, y;
cin>>n>>x>>y;if(y ==0){
cout<<n<<'
';return0;}int ans = n-((y-1)/x+1);if(ans <0)ans =0;
cout<< ans <<'
';return0;}