洛谷题单 【入门1】顺序结构

1.B2002

#include 

int main(void) {
    printf("Hello,World!");
    return 0;
}

 2.B2025

#include 

int main(void) {
    printf("  *\n ***\n*****\n ***\n  *");
    return 0;
}

3.P1000

#include 

int main(void) {
    printf("                ********\n               ************\n               ####....#.\n             #..###.....##....\n             ###.......######              ###            ###\n                ...........               #...#          #...#\n               ##*#######                 #.#.#          #.#.#\n            ####*******######             #.#.#          #.#.#\n           ...#***.****.*###....          #...#          #...#\n           ....**********##.....           ###            ###\n           ....****    *****....\n             ####        ####\n           ######        ######\n##############################################################\n#...#......#.##...#......#.##...#......#.##------------------#\n###########################################------------------#\n#..#....#....##..#....#....##..#....#....#####################\n##########################################    #----------#\n#.....#......##.....#......##.....#......#    #----------#\n##########################################    #----------#\n#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#\n##########################################    ############\n");
    return 0;
}

4.P1001

#include 

int main(void) {
    int a,b,sum;
    scanf("%d%d",&a,&b);
    sum=a+b;
    printf("%d",sum);
    return 0;
}

5.B2005

#include 

int main(void) {
    char ch;
    scanf("%c",&ch);
    for(int i=0;i<3;i++){
        for(int j=2-i;j>0;j--)printf(" ");
        for(int j=0;j<2*i+1;j++)printf("%c",ch);
        printf("\n");
    }
    return 0;
}

6.5703

#include 

int main(void) {
    int a,b,c;
    scanf("%d%d",&a,&b);
    c=a*b;
    printf("%d",c);
    return 0;
}

7.5704

#include 

int main(void) {
    char c;
    scanf("%c",&c);
    c=c-32;
    printf("%c",c);
    return 0;
}

8.B5705

#include 

int main(void) {
    char a,b,c,d,ch;
    scanf("%c%c%c%c%c",&a,&b,&c,&ch,&d);
    printf("%c%c%c%c%c",d,ch,c,b,a);
    return 0;
}

9.B5706

#include 

int main(void) {
    double t,a;
    int n,b;
    scanf("%lf%d",&t,&n);
    a=t/n;
    b=2*n;
    printf("%.3f\n%d",a,b);
    return 0;
}

10.B5708

#include 
#include 

int main(void) {
    double a,b,c,p,s;
    scanf("%lf%lf%lf",&a,&b,&c);
    p=(a+b+c)/2;
    s=sqrt(p*(p-a)*(p-b)*(p-c));
    printf("%.1f",s);
    return 0;
}

11.B5707

#include 

int main(void) {
    int s,v,h,m,temp;
    scanf("%d%d",&s,&v);
    m=(s+v-1)/v+10;
    temp=8*60-m;
    if(temp>=0){

    }else{
        temp=-temp;
        temp=24*60-temp;
    }
    h=temp/60;
    m=temp%60;
    if(h<10)printf("0");
    printf("%d:",h);
    if(m<10)printf("0");
    printf("%d",m);
    return 0;
}

12.B2029

#include 

int main(void) {
    int h,r,n;
    scanf("%d%d",&h,&r);
    double v;
    v=3.14*r*r*h;
    n=(20*1000+v-1)/v;
    printf("%d",n);
    return 0;
}

13.B1425

#include 

int main(void) {
    int a,b,c,d,e,f,temp;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    temp=(c*60+d)-(a*60+b);
    e=temp/60;
    f=temp%60;
    printf("%d %d",e,f);
    return 0;
}

14.B1421

#include 

int main(void) {
    int a,b,c,temp;
    scanf("%d%d",&a,&b);
    temp=a*10+b;
    c=temp/(1*10+9);
    printf("%d",c);
    return 0;
}

15.P3954

#include 

int main(void) {
    int a,b,c,temp;
    scanf("%d%d%d",&a,&b,&c);
    temp=a*0.2+b*0.3+c*0.5;
    printf("%d",temp);
    return 0;
}

你可能感兴趣的:(算法,洛谷,c语言)