【HDOJ 2020.09.29】一些语法水题ByVJ
【摘要】
By VJ
小抄c版v2
A
//上次不是做过了
#include<stdio.h>
int main(){
char a, b, c, t;
while(scanf("%c%c...
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;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
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;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
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;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
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;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
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;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
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;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
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;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
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;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
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;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
文章来源: gwj1314.blog.csdn.net,作者:小哈里,版权归原作者所有,如需转载,请联系作者。
原文链接:gwj1314.blog.csdn.net/article/details/113566494
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)