• 欢迎光临~

实验二作业

开发技术 开发技术 2022-10-19 次浏览
实验二作业
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
    char a;
    while(scanf_s("%c",&a) != EOF)
    { 
        switch (a)
        {
        case'r':printf("STOP!n"); break;
        case'g':printf("GOGOGOn"); break;
        case'y':printf("Wait a minuten"); break;
        default:printf("Something must be wrongn"); break;
        }
        getchar();
    }
    return 0;
}
#include<stdio.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    int line, col;
    for (line = 1; line <= 9; line++)
    {
        for (col = 1; col <= line; col++)
        {
            int a;
            a = line * col;
            printf("%d*%d = %.2d  ",col,line,a);
        }
        printf("n");
    }
    return 0;
}

实验二作业

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int ba1(int);
int ba2(int);
int ba3(int);
int main()
{
    int a,b;
    scanf_s("%d",&a);
    for (b = a; b >= 1; b--)
    {
        int c;
        for (c = a; c > b; c--)
            printf("t");
        ba1(b);
        for (c = a; c > b; c--)
            printf("t");
        ba2(b);
        for (c = a; c > b; c--)
            printf("t");
        ba3(b);
        printf("n");
    }
    return 0;
}
int ba1(int a)
{
    int b;
    for (b = 2 * a - 1; b >= 1; b--)
    {
        printf(" o t");
    }
    printf("n");
}
int ba2(int a)
{
    int b;
    for (b = 2 * a - 1; b >= 1; b--)
    {
        printf("<H>t");
    }
    printf("n");
}
int ba3(int a)
{
    int b;
    for (b = 2*a-1; b >= 1; b--)
    {
        printf("I It");
    }
    printf("n");
}

实验二作业

实验二作业

 


#include<stdlib.h>
#include<math.h>
int main()
{
    int n, a;
    double  c, b;
    while (scanf_s("%d%d", &n,&a) != EOF)
    {
        int d = 0;
        double s = 0;
        for (c=1; c <= n; c++)
        {
            d = 10*d + a;
            b = c / d;
                s += b;
        }
        printf("n = %d,a = %d,s = %lfn", n, a, s);
    }
    return 0;
}

实验二作业

 

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
    printf("猜猜2022年11月的Lucky day是哪天n开始喽,你有三次机会n");
    srand(time(0));
    int a, b, c;
    b = rand() % 30 + 1;
    for (a = 1; a <= 3; a++)
    {
        scanf_s("%d",&c);
        if (c < b)
            printf("你猜的日期早了,还没到Lucky day呢n");
        if (c > b)
            printf("你猜的日期晚了,Lucky day已经过了n");
        if (c == b) 
        {
            printf("哇,猜中了,不愧是你呀n");
            break;
        }    
        if (a == 3)
            printf("次数用完了,偷偷告诉你吧,Lucky day是 %d",b);
    }
    return 0;
}

实验二作业

实验二作业

 

程序员灯塔
转载请注明原文链接:实验二作业
喜欢 (0)
违法和不良信息举报电话:022-22558618 举报邮箱:dljd@tidljd.com