2000
#include <stdio.h>int main(){
char a,b,c,d,x,y,z;while(scanf("%c%c%c%c",&a,&b,&c,&d) != EOF){
x=a<b?a:b; x=x<c?x:c;z=a>b?a:b;z=z>c?z:c;y=a+b+c-x-z;printf("%c %c %c\n",x,y,z);}}
2001
#include <stdio.h>
#include <math.h>int main(){
double a,b,c,d;double x;while(scanf("%lf %lf %lf %lf",&a,&b,&c,&d)!= EOF){
x=sqrt((double)(pow(d-b,2)+pow(c-a,2)));printf("%.2lf\n",x);}return 0;}
2002
#include<stdio.h>
#define PI 3.1415927
int main() {
double a;while(scanf("%lf",&a)!=EOF) printf("%.3lf\n",(double)4/3*PI*a*a*a); return 0;
}
2003
#include <stdio.h>
int main(void)
{
double x; while(scanf("%lf", &x) != EOF) {
if(x > 0) printf("%.2lf\n", x); else printf("%.2lf\n", -x); } return 0;
}
2004
#include <stdio.h>
int main(void)
{
int a;while(scanf("%d",&a)!=EOF){
if(a>=90&&a<=100)printf("A\n");if(a>=80&&a<=89)printf("B\n");if(a>=70&&a<=79)printf("C\n");if(a>=60&&a<=69)printf("D\n");if(a>=0&&a<=59)printf("E\n");if(a<0||a>100)printf("Score is error!\n");} return 0;
}
2005
地球绕太阳运行周期为365天5小时48分46秒(合365.24219天)即一回归年(tropical year)。公历的平年只有365日,比回归年短约0.2422 日,所余下的时间约为每四年累计一天,故第四年于2月末加1天,使当年的历年长度为366日,这一年就为闰年。现行公历中每400年有97个闰年。按照每四年一个闰年计算,平均每年就要多算出0.0078天,这样经过四百年就会多算出大约3天来。因此每四百年中要减少三个闰年。所以公历规定:年份是整百数时,必须是400的倍数才是闰年;不是400的倍数的世纪年,即使是4的倍数也不是闰年。
这就是通常所说的:四年一闰,百年不闰,四百年再闰。 例如,2000年是闰年,2100年则是平年。
#include <stdio.h>
int main()
{
int a[12]={
31,28,31,30,31,30,31,31,30,31,30,31};int b[12]={
31,29,31,30,31,30,31,31,30,31,30,31};int m,n,p;int t=0;int i,j;while(scanf("%d/%d/%d",&m,&n,&p)!=EOF){
t=0;if ((m % 4 == 0 && m % 100) || m % 400 == 0){
if (n==1)printf ("%d\n",p);else{
for (i=0;i<n-1;i++)t=t+b[i];t=t+p; printf ("%d\n",t);}}else {
if (n==1)printf ("%d\n",p);else{
for (i=0;i<n-1;i++)t=t+a[i];t=t+p;printf ("%d\n",t);} }}return 0;
}
2006
#include <stdio.h>
int main()
{
int n, a, sum, i;while(scanf("%d", &n) != EOF){
sum = 1;for(i = 0; i < n; i ++){
scanf("%d", &a);if(a%2==1)sum = sum * a;}printf("%d\n", sum);}return 0;
}
2007
这一句话要看懂,不然不知道题目什么意思,也就是两个数之间的所有数。并且自己要按大小排序。
#include <stdio.h>
int main()
{
int i,a,b,n,m,t;while(scanf ("%d %d",&a,&b)!=EOF){
m=n=0;if (a>b){
t=a;a=b;b=t;}for (i=a;i<=b;i++){
if (i%2==0){
m=m+i*i;}else{
n=n+i*i*i;}}printf("%d %d\n",m,n);}return 0;
}
2008
#include <stdio.h>
int main()
{
int n, i;double a;int sum1,sum2,sum3;while(scanf("%d", &n) != EOF){
sum1=sum2=sum3=0;for(i = 0; i < n; i ++){
scanf("%lf", &a);if(a<0)sum1++;if(a==0)sum2++;if(a>0) sum3++;}if(n!=0)printf("%d %d %d\n",sum1,sum2,sum3);elsebreak;}return 0;
}
2009
#include <stdio.h>
#include <math.h>
int main()
{
int m,i;double n,sum;while(scanf("%lf", &n) != EOF){
sum=n;scanf("%d", &m);for(i=0;i<m-1;i++){
sum=sum+sqrt(n);n=sqrt(n);}printf ("%.2lf\n",sum); }
}
2010
这个格式问题弄了我半个小时,实际上就是用好那个g的标志位。
#include <stdio.h>
int main()
{
int i,a,b,n,m,t,k,g;while(scanf ("%d %d",&a,&b)!=EOF){
if (a>b){
t=a;a=b;b=t;}g=0;for (i=a;i<=b;i++){
m=i/100;n=(i/10)%10;k=i%10;if (i==m*m*m+n*n*n+k*k*k){
if(g==0)printf("%d",i);if(g!=0)printf(" %d",i);g++;}}if(g>=1)printf("\n");if(g==0)printf("no\n");}return 0;
}
2011
#include <stdio.h>
#include <stdlib.h>
#include <math.h>int main()
{
int m, n, i;double sum ,s= 1;while(scanf("%d",&m)!=EOF){
while(m--){
sum =0;scanf("%d",&n);for(i=1; i<=n; i++)sum+= s/i * pow(-1, i-1);printf("%.2lf\n",sum);}}return 0;
}
2039
#include<stdio.h>
int main()
{
int n,j;double a,b,c;scanf("%d",&n);while(n--){
scanf("%lf%lf%lf",&a,&b,&c);if(a+b>c&&a+c>b&&b+c>a)printf("YES\n");elseprintf("NO\n");}return 0;
}