HDU 2000 - 2009

2000 

题目描述:
输入三个字符后,按各字符的ASCII码从小到大的顺序输出这三个字符。

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    char a[3];
    while(cin>>a)
    {
        sort(a,a+3);
        cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
    }
    return 0;
}
Run ID Submit Time Judge Status Pro.ID Exe.Time Exe.Memory Code Len. Language Author
10356973 2014-03-21 00:42:44 Accepted 2000 15MS 344K 218 B G++ MP131420



2001

题目描述:

输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。

#include <stdio.h>
#include <cmath>
int main()
{
    double x1,x2,y1,y2;
    while(~scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2))
    {
       printf("%.2lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
    }
    return 0;
}
Run ID Submit Time Judge Status Pro.ID Exe.Time Exe.Memory Code Len. Language Author
10357013 2014-03-21 00:50:40 Accepted 2001 0MS 244K 226 B G++ MP131420



2002

题目描述:
根据输入的半径值,计算球的体积。

#include<iostream>
using namespace std;
int main()
{
  double m,n;
  while(cin>>n)
  {
     double pi=3.1415927;
    m=(double)4/3*pi*n*n*n;
     printf ("%.3lf",m) ;
     cout<<endl;
             } 
               return 0;
                }
Run ID Submit Time Judge Status Pro.ID Exe.Time Exe.Memory Code Len. Language Author
7484961 2013-01-07 19:56:04 Accepted 2002 15MS 336K 257 B C++ MP131420




2003

题目描述:

求实数的绝对值。

#include <stdio.h>
#include <math.h>
int main()
{
    double a;
    while(~scanf("%lf",&a))
    {
        printf("%.2lf\n",fabs(a));
    }
}
Run ID Submit Time Judge Status Pro.ID Exe.Time Exe.Memory Code Len. Language Author
10357034 2014-03-21 00:57:17 Accepted 2003 15MS 244K 151 B G++ MP131420



2004

题目描述:

输入一个百分制的成绩t,将其转换成对应的等级,具体转换规则如下:90~100为A ;   80~89为B;     70~79为C;     60~69为D;    0~59为E;
#include <iostream>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
        if(n<0||n>100) cout<<"Score is error!"<<endl;
        else if(n<60)cout<<"E"<<endl;
        else if(n<70)cout<<"D"<<endl;
        else if(n<80)cout<<"C"<<endl;
        else if(n<90)cout<<"B"<<endl;
        else cout<<"A"<<endl;
    }
    return 0;
}
Run ID Submit Time Judge Status Pro.ID Exe.Time Exe.Memory Code Len. Language Author
10357924 2014-03-21 11:43:25 Accepted 2004 0MS 364K 363 B G++ MP131420




2005

题目描述:

给定一个日期,输出这个日期是该年的第几天。

#include <stdio.h>
int main()
{
    int a[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
    int y,m,d;
    while(~scanf("%d/%d/%d",&y,&m,&d))
    {
        int sum=d;
        for(int i=0;i<m;i++)sum+=a[i];
        if((y%4==0&&y%100!=0||y%400==0)&&m>2) sum++;
        printf("%d\n",sum);
    }
}
Run ID Submit Time Judge Status Pro.ID Exe.Time Exe.Memory Code Len. Language Author
10358023 2014-03-21 12:09:05 Accepted 2005 15MS 228K 309 B G++ MP131420




2006

题目描述:

给你n个整数,求他们中所有奇数的乘积。

#include <iostream>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
        int a,sum=1;
        for(int i=0;i<n;i++)
        {
            cin>>a;
            if(a%2!=0)sum*=a;
        }
        cout<<sum<<endl;
    }
    return 0;
}
Run ID Submit Time Judge Status Pro.ID Exe.Time Exe.Memory Code Len. Language Author
10357940 2014-03-21 11:48:09 Accepted 2006 0MS 364K 273 B G++ MP131420



2007

题目描述:

给定一段连续的整数,求出他们中所有偶数的平方和以及所有奇数的立方和。

#include <stdio.h>

int main()
{
    int x , y, temp, sum1, sum2;
    while(scanf("%d %d", &x, &y) != EOF)
    {
        sum1 = 0;
        sum2 = 0;
        if(x > y)
        {
            temp = x;
            x = y;
            y = temp;
        }
        for(; x <= y; x++)
        {
            if( x % 2 == 0)
            {
                sum1 += x * x;
            }
            else
                sum2 += x * x * x;
        }
    printf("%d %d\n", sum1, sum2);        
    }
    return 0;
}
  me Judge Status Pro.ID Exe.Time Exe.Memory Code Len. Language Author
7702896 2013-03-06 21:01:56 Accepted 2007 0MS 220K 527 B G++ MP131420



2008

题目描述:

统计给定的n个数中,负数、零和正数的个数。

#include <iostream>
using namespace std;
int main()
{
    int n,i;
    while(cin>>n)
    {
        if(n==0)break;
        int a=0,b=0,c=0;double x;
        for(i=0;i<n;i++)
        {
            cin>>x;
            if(x<0)a++;
            else if(x>0)c++;
            else b++;
        }
            cout<<a<<" "<<b<<" "<<c<<endl;
    }
    return 0;
}
Run ID Submit Time Judge Status Pro.ID Exe.Time Exe.Memory Code Len. Language Author
10358078 2014-03-21 12:24:02 Accepted 2008 0MS 400K 373 B G++ MP131420




2009

题目描述:

数列的第一项为n,以后各项为前一项的平方根,求数列的前m项的和。

#include <stdio.h>
#include <math.h>
int main()
{
    double n,m;
    while(~scanf("%lf%lf",&n,&m))
    {
        double sum=n;
        for(int i=1; i<m; i++)
        {
            sum+=sqrt(n);
            n=sqrt(n);
        }
        printf("%.2lf\n",sum);
    }
    return 0;
}
Run ID Submit Time Judge Status Pro.ID Exe.Time Exe.Memory Code Len. Language Author
10358057 2014-03-21 12:18:42 Accepted 2009 0MS 244K 298 B G++ MP131420
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值