【HDOJ 2020.09.29】一些语法水题ByVJ

By VJ

在这里插入图片描述

小抄c版v2

A

//上次不是做过了
#include<stdio.h>
int main(){
	char a, b, c, t;
	while(scanf("%c%c%c\n",&a,&b,&c)!=EOF){
		if(a>b){t=a;a=b;b=t;}
		if(a>c){t=a;a=c;c=t;}
		if(b>c){t=b;b=c;c=t;}
		printf("%c %c %c\n",a,b,c);
	}
	return 0;
}


B

//I64不香么
#include<stdio.h>
int main(){
	__int64 a, b, sum;
	while(scanf("%I64X%I64X",&a,&b)!=EOF){
		sum = a+b;
		if(sum<0)printf("-%I64X\n",-sum);
		else printf("%I64X\n",sum);
	}
	return 0;
}

C

#include<stdio.h>
#include<math.h>
int days[12]= {31,28,31,30,31,30,31,31,30,31,30,31};
int main(){
	int y, m, d;
	while(scanf("%d/%d/%d",&y,&m,&d)!=EOF){
		days[1] = 28;
		if(y%4==0&&y%100!=0 || y%400==0)days[1]++;
		for(int i = 0; i < m-1; i++)
			d += days[i];
		printf("%d\n",d);
	}
	return 0;
}

D

#include<stdio.h>
int main(){
	int n, m;
	while(scanf("%d%d",&n,&m)!=EOF){
		int sum = 0, tmp = 0, num = 0;
		for(int i = 1; i <= n; i++){
			tmp += 2;
			num++;
			sum += tmp;
			if(i==n){
				printf("%d",sum/num);
				sum = 0;
				num = 0;
				continue;
			}
			if(i%m==0){
				printf("%d ",sum/num);
				sum = 0;
				num = 0;
			}
		}
		printf("\n");
	}
	return 0;
}

E

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

F

#include<stdio.h>
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		int h1,h2,m1,m2,s1,s2;
		scanf("%d%d%d%d%d%d",&h1,&m1,&s1,&h2,&m2,&s2);
		int s = (s1+s2)%60;
		int m = (m1+m2+(s1+s2)/60)%60;
		int h = h1+h2+(m1+m2+(s1+s2)/60)/60;
		printf("%d %d %d\n",h,m,s);
	}
	return 0;
}

G

#include<stdio.h>
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		int a, b;
		scanf("%d%d",&a,&b);
		if(a%b==0)printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

H

#include<stdio.h>
int gcd(int a, int b){return b?gcd(b,a%b):a;}
int main(){
	int a, b;
	while(scanf("%d%d",&a,&b)!=EOF){
		printf("%d\n",a/gcd(a,b)*b);
	}
	return 0;
}

I

#include<stdio.h>
int main(){
	int sc;
	while(scanf("%d",&sc)!=EOF){
		if(sc>=90&&sc<=100)printf("A\n");
		if(sc>=80&&sc<=89)printf("B\n");
		if(sc>=70&&sc<=79)printf("C\n");
		if(sc>=60&&sc<=69)printf("D\n");
		if(sc>=0&&sc<=59)printf("E\n");
		if(sc<0||sc>100)printf("Score is error!\n");
    }
    return 0;
}
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 技术工厂 设计师:CSDN官方博客 返回首页