2.1 一个矩形桌子砍去一角剩下几条边
//小朋友
#include<stdio.h>
int main()
{
int a,b;//桌长宽
int m,n;//砍角长宽
scanf("%d%d",&a,&b);
scanf("%d%d",&m,&n);
if(a==m&&b==n) printf("3\n");
else if(a==m) printf("4\n");
else if(b==n) printf("4\n");
else printf("5\n");
return 0;
}
//犇犇
#include<cstdio>
int n,m,a,b;
int main()
{
scanf("%d%d",&n,&m);
scanf("%d%d",&a,&b);
int ans=5;
if (a==n) ans--;
if (b==m) ans--;
printf("%d",ans);
}
//小朋友
#include<stdio.h>
int main(){
int a,b;
char x,ccc;
scanf("%d%c%c%c%d",&a,&ccc,&x,&ccc,&b);
if(x=='+') printf("%d\n",a+b);
else if(x=='-') printf("%d\n",a-b);
else if(x=='*') printf("%d\n",a*b);
else if(x=='/'&&b!=0) printf("%d\n",a/b);
else if(x=='%'&&b!=0) printf("%d\n",a%b);
else printf("ERROR\n");
return 0;
}
//犇犇
#include<cstdio>
int n,m;
char c,cc;
int main()
{
while (scanf("%d%c%c%c%d",&n,&c,&cc,&c,&m)!=EOF)
{
switch(cc)
{
case '+':printf("%d\n",n+m);break;
case '-':printf("%d\n",n-m);break;
case '*':printf("%d\n",n*m);break;
case '/':if (m==0) printf("ERROR\n"); else printf("%d\n",n/m);break;
case '%':if (m==0) printf("ERROR\n"); else printf("%d\n",n%m);break;
default:printf("ERROR\n");
}
}
}
2.3 三角形
//小朋友
#include<stdio.h>
#include<math.h>
int main(){
double a,b,c;
double s,x;//面积和周长
scanf("%lf%lf%lf",&a,&b,&c);
if(a+b>c&&b+c>a&&a+c>b)
{
x=a+b+c;
double p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
printf("%.2lf %.2lf\n",s,x);
}
else printf("no triangle\n");
return 0;
}
//犇犇
#include<cstdio>
#include<cmath>
double a,b,c,s,p;
int main()
{
scanf("%lf%lf%lf",&a,&b,&c);
if ((a+b<c)|| (a+c<b) || (b+c<a))
{
printf("no triangle");
return 0;
}
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
printf("%.2lf %.2lf",s,a+b+c);
}
//小朋友
#include<stdio.h>
int main(){
float year,hour;
float sum;
scanf("%f%f",&year,&hour);
if(year<5)
{
if(hour<=40)
sum=30*hour;
else
sum=45*(hour-40)+1200;
}
else
{
if(hour<=40)
sum=50*hour;
else
sum=75*(hour-40)+2000;
}
printf("%.2f\n",sum);
return 0;
//犇犇
#include<cstdio>
#include<cmath>
int y;
double t;
int main()
{
while (scanf("%d%lf",&y,&t)!=EOF)
{
int m;
m= y>=5 ? 50 : 30;
double ans=t>40? 40*m+(t-40)*1.5*m: t*m;
printf("%.2lf\n",ans);
}
}
//小朋友
#include<stdio.h>
#include<math.h>
int main(){
double a,m;
scanf("%lf",&a);
m=sqrt(a);
if((m-(int)m)==0)
{
if((int)a%2==0) printf("Even special number\n");
else printf("Odd special number\n");
}
else printf("No\n");
return 0;
}
//犇犇:
#include<cstdio>
#include<cmath>
int n;
int main()
{
while (scanf("%d",&n)!=EOF)
{
if (sqrt(n)!=int(sqrt(n))) printf("No\n");
else if (n%2==1) printf("Odd special number\n");
else printf("Even special number\n");
}
}
//小朋友
#include<stdio.h>
double max(double a,double b){ return a>b? a:b;}
double min(double a,double b){ return a<b? a:b;}
int main(){
double open,high,low,close;
while(scanf("%lf%lf%lf%lf",&open,&high,&low,&close)!=EOF)
{
if(close<open) printf("BW-Solid");
else if(close>open) printf("R-Hollow");
else if(close==open) printf("R-Cross");
if(low<min(open,close)&&high>max(open,close)) printf(" with Lower Shadow and Upper Shadow");
else if(high>max(open,close)) printf(" with Upper Shadow");
else if(low<min(open,close)) printf(" with Lower Shadow");
printf("\n");
}
return 0;
}
//犇犇
#include<cstdio>
#include<cmath>
double o,h,l,c;
double max(double a,double b) {return a>b? a:b;}
double min(double a,double b) {return a<b? a:b;}
int main()
{
while (scanf("%lf%lf%lf%lf",&o,&h,&l,&c)!=EOF)
{
if (o>c) printf("BW-Solid");
else if (o==c) printf("R-Cross");
else printf("R-Hollow");
if (l<min(o,c) && h>max(o,c))
printf(" with Lower Shadow and Upper Shadow");
else if (h>max(o,c)) printf(" with Upper Shadow");
else if (l<min(o,c)) printf(" with Lower Shadow");
//else if (h>max(o,c)) printf("with Upper Shadow");
printf("\n");
}
}
//小朋友(此题为大坑,坑死窝了_(Xзゝ∠)_)
#include<stdio.h>
int main(){
int a,b;
int c,d;
int i,j;
while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF)
{
i=a+c;j=b+d;
if(i!=0&&j!=0&&j!=1) printf("%d+%di\n",i,j);
else if(i!=0&&j==1) printf("%d+i\n",i);
else if(i==0&&j!=0&&j!=1) printf("%di\n",j);
else if(i==0&&j==1) printf("i\n");
else if(j==0) printf("%d\n",i);
}
return 0;
//犇犇
#include<cstdio>
#include<cmath>
int a,b,c,d;
int main()
{
scanf("%d%d%d%d",&a,&b,&c,&d);
if (a+c==0 && b+d==0) printf("0");
else if (a+c==0 && b+d!=0)
{
if (b+d==1) printf("i");else
printf("%di",b+d);
}
else if (a+c!=0 && b+d==0) printf("%d",a+c);
else {
if (b+d==1) printf("%d+i",a+c);else
printf("%d+%di",a+c,b+d);
}
}