杭电ACM 100 ——2003~2006

//2003
//求绝对值


#include<stdio.h>
#include<math.h>
int main()
{
	double	x;
	double  result;
	
	while((scanf("%lf",&x) !=EOF))
	{
		result=fabs(x);                //取绝对值函数
		
		printf("%.2lf\n",result);
	}	
	
	return 0;
	
 } 

123
123.00
-234.00
234.00
//2004
//成绩转换
//输入一个百分制的成绩t,将其转换成对应的等级
#include<stdio.h>
int main()
{
	int t,m;
	
	while((scanf("%d",&t)) !=EOF)
	{
		m=t/10;
		if(m==9||m==10)
			printf("A\n");
		else if(m==8)
			printf("B\n");
		else if(m==7)
			printf("C\n");
		else if(m==6)
			printf("D\n");
		else if(m<6)
			printf("E\n");
		else
			printf("Score is error!\n");	
		
		
	}
	
	
	return 0;
 } 

56
E
67
D
100
A
123
Score is error!

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

#include<stdio.h>
int main()
{
	int year,month,day,i,days;
	int a[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	
	while( (scanf("%d/%d/%d",&year,&month,&day) !=EOF ) )
	{
		days=0;	
		for(i=0; i<month; i++)
		{
			days+=a[i];
		}
			days+=day;
		if(((year%4 == 0 && year%100 != 0 )|| year%400 == 0)&&month>=3)			//判断闰年 
		{
			printf("%d\n",days+1);
		 }
		else
		{
			printf("%d\n",days);
		}
		
		
	
		
		
	}
	
	return 0;
}

1985/1/20
20
2006/3/12
71
//2006
//给你n个整数,求他们中所有奇数的乘积。

#include<stdio.h>
#include <algorithm>
int main()
{
	int a[20];
	int ans,i,n;
	while((scanf("%d",&n) !=EOF))
	{
		
		ans=1;
		for(i=0; i<n; i++)
		{
			scanf("%d",&a[i]);
			if(a[i]%2==1)
			{
				ans=ans*a[i];
		 	} 	
		}
		
		 printf("%d\n",ans);
	}
	
	
	return 0;
}

3 1 2 3
3
4 2 3 4 5
15

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值