www.bersaty.com

hdoj 刚入门~把11页A了一些~~

2000~2007

//2000  http://acm.hdu.edu.cn/showproblem.php?pid=2000
#include<stdio.h>
#include<string.h>
void main()
{
    char str[4],t;
    int i;
    while(scanf("%s",str)!=EOF)
    {
        for(i=0;i<2;i=i++)
        {
            if(str[i]>str[i+1])
            {
                t=str[i];
                str[i]=str[i+1];
                str[i+1]=t;
            }
        }
        for(i=0;i<2;i=i++)
        {
            if(str[i]>str[i+1])
            {
                t=str[i];
                str[i]=str[i+1];
                str[i+1]=t;
            }
        }
        printf("%c %c %c\n",str[0],str[1],str[2]);
    }
}
//2001 
#include<stdio.h>
#include<math.h>
void main()
{
    float x1,y1,x2,y2,d,s;
    while(scanf("%f %f %f %f",&x1,&y1,&x2,&y2)!=EOF)
    {
        s=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
        d=(float)sqrt(s);
        printf("%.2f\n",d);
    }
}
//2002
#include<iostream>
#define PI 3.1415927
using namespace std;
int main()
{
    double n,v;
    while(cin>>n)
    {
        v=(4/3.0)*PI*n*n*n;
        printf("%.3lf\n",v);
    }
    return 0;
}
//2003
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    double a;
    while(cin>>a)
    {
            printf("%.2f\n",fabs(a));
    }
    return 0;
}
//2004
#include<iostream>
using namespace std;
int main()
{
    double n;
    while(cin>>n)
    {
        if(n<=100&&n>=90) {cout<<"A"<<endl;}
        if(n<=89&&n>=80) {cout<<"B"<<endl;}
        if(n<=79&&n>=70) {cout<<"C"<<endl;}
        if(n<=69&&n>=60) {cout<<"D"<<endl;}
        if(n<=59&&n>=0) {cout<<"E"<<endl;}
        if(n>100||n<0) {cout<<"Score is error!"<<endl;}
    }
    return 0;
}
//2005
#include<iostream>
using namespace std;
int main()
{
    int y,m,d;
    int a[13]={0,0,31,59,90,120,151,181,212,243,273,304,334};
    while(scanf("%d/%d/%d",&y,&m,&d)!=EOF)
    {
        if((y%400==0)||(y%4==0&&y%100!=0))
            if(m>2)
                printf("%d\n",a[m]+d+1);
            else
                printf("%d\n",a[m]+d);
        else
            printf("%d\n",a[m]+d);
    }
    return 0;
}
//2006
#include<iostream>
using namespace std;
int main()
{
    int n,m,s;
    while(cin>>n)
    {
        s=1;
        while(n--)
        {
            cin>>m;
            if(m%2!=0)
                s*=m;
        }
        cout<<s<<endl;
    }
    return 0;
}
//2007
#include<iostream>
using namespace std;
int main()
{
    int m,n,x,y,t;
    while(scanf("%d %d",&m,&n)!=EOF)
    {
        x=0,y=0;
        if(m>n)
        {
            t=m;
            m=n;
            n=t;
        }
        while(m<=n)
        {
            if(m%2==0)
                x+=(m*m);
            else
                y+=(m*m*m);
            m++;
        }
        printf("%d %d\n",x,y);
    }
    return 0;
}
posted @ 2011-06-27 20:43  bersaty  阅读(259)  评论(0编辑  收藏  举报