2022.5.5

/* 2022.5.5*/
/* guess.c -- 一个拖沓且错误的猜数字程序 */
//#include <stdio.h>
//int main()
//{
//    int guess = 1;
//
//    printf("pick an integer from 1 to 100 .i will try to guess ");
//    printf("it.\nrespond withva y if my guess is right and with");
//    printf("\nan n if it is wrong.\n");
//    printf("uh...is your number %d?\n", ++guess);
//    printf("i knew i could do it!\n");
//
//    return 0;
//}
//pick an integer from 1 to 100.i will try to guess it.
//respond withva y if my guess is rightand with
//an n if it is wrong.
//uh...is your number 2 ?
//i knew i could do it!
//从1到100选一个整数,我试着猜一下。
//回答,如果我猜对了,然后回答
//如果它是错的,那就错了。
//嗯… 你是二号吗 ?
//我就知道我能做到!


/* showcharl.c -- 有较大I/O 问题的程序 */
//#include <stdio.h>
//void display(char cr, int lines, int width);
//int main()
//{
//    int ch;                            /* 待打印字符*/
//    int rows, cols;                   /* 行数和列数*/
//    printf("enter a character and two integers:\n");
//    while ((ch = getchar()) != '\n')
//    {
//        scanf("%d %d", &rows, &cols);  
//        display(ch, rows, cols);
//        printf("enter another character and two integers;\n");
//        printf("enter a newline to quit.\n");
//
//    }
//    printf("bye.\n");
//
//    return 0;
//}
//void display(char cr, int lines, int width)
//{
//    int row, col;
//    for (row = 1; row <= lines; row++)
//    {
//        for (col = 1; col <= width; col++)
//            putchar(cr);
//        putchar('\n'); /* 结束一行并开始新的一行*/
//    }
//}
//enter a characterand two integers :
//c 2 3
//ccc
//ccc
//enter another character and two integers;
//enter a newline to quit.
//bye.
//输入一个字符和两个整数:
//c 2 3
//ccc
//ccc
//输入另一个字符和两个整数;
//输入换行符退出。
//再见。

/* showchar2.c -- 按指定的行列打印字符 */
//#include <stdio.h>
//void display(char cr, int lines, int width);
//int main()
//{
//    int ch;                     /* 待打印字符 */
//    int rows, cols;              /* 行数和列数 */
//
//    printf("enter a character and two integers:\n");
//    while ((ch = getchar()) != '\n')
//    {
//        if (scanf("%d %d", &rows, &cols) != 2)  /*scanf 函数会去掉 空格,之后的一个| */
//            break;
//        display(ch, rows, cols);
//        while (getchar() != '\n')   /* while 的作用是过滤 \n */
//            continue;
//        printf("enter another character and two integers;\n");
//        printf("enter a newline to quit.\n");
//
//    }
//    printf("bye.\n");
//
//
//    return 0;
//}
//
//void display(char cr, int lines, int width)
//{
//    int row, col;
//
//    for (row = 1; row <= lines; row++)
//    {
//        for (col = 1; col <= width; col++)
//            putchar(cr);
//        putchar('\n');            /* 结束一行并开始新的一行 */
//    }
//}
//enter a characterand two integers :
//c 1 2
//cc
//enter another character and two integers;
//enter a newline to quit.
//!3 6
//!!!!!!
//!!!!!!
//!!!!!!
//enter another character and two integers;
//enter a newline to quit.
//输入一个字符和两个整数:
//c 1 2
//cc
//输入另一个字符和两个整数;
//输入换行符退出。
//!  3个6
//!!
//!!
//!!
//输入另一个字符和两个整数;
//输入换行符退出。


/* checking.c -- 输入验证------------------------------------------------不对 */
//#include <stdio.h>
//#include <stdbool.h>
///* 验证输入的是一个整数 */
//long get_long(void);
///* 验证范围是否有效 */
//bool bad_limits(long begin, long end, long low, long high);
///* 计算a~b 的整数平方和 */
//double sum_squares(long a, long b);
//int main(void)
//{
//    const long MIN = -10000000L;           /* 范围的下限 */
//    const long MAX = +10000000L;           /* 范围的上限 */
//    long start;                             /* 用户指定的范围最小值 */
//    long stop;                          /* 用户指定的范围最大值 */
//    double answer;
//
//    printf("this program computes the sum of the squares of "
//    "integers in a range.\nthe lower bound should not "
//    "be less than -10000000 and\nthe upper bound "
//    "should not be more than +10000000.\nenter the"
//    "limits (enter 0 for both limits to quit):\n"
//    "lower limit: ");
//    start = get_long();
//    printf("upper limit: ");
//    stop = get_long();
//    while (start != 0 || stop != 0)
//    {
//        if (bad_limits(start, stop, MIN, MAX))
//            printf("please try again.\n");
//        else
//        {
//            answer = sum_squares(start, stop);
//            printf("the sum of the squares of the integers ");
//            printf("from %ld to %ld is %g\n", start,stop,answer);
//
//        }
//        printf("enter the limits (enter 0 for both limits to quit):\n");
//        printf("lower limit: ");
//        start = get_long();
//        printf("upper limit: ");
//        stop = get_long();
//    }
//    printf("done.\n");
//
//    return 0;
//}
//
//long get_long(void)
//{
//    long input;
//    char ch;
//
//    while (scanf("%ld", &input) != 1)
//    {
//        while ((ch = getchar()) != '\n')
//            putchar(ch);                         /* 处理错误输入 */
//        printf(" is not an integer.\nplease enter an ");
//        printf("integer value, such as 25, -178, or 3: ");
//
//    }
//    return input;
//}
//
//double sum_squares(long a, long b)
//{
//    double total = 0;
//    long i;
//
//    for (i = a; i <= b; i++)
//        total += (double)i * (double)i;
//
//    return total;
//}
//
//bool bad_limits(long begin, long end, long low, long high)
//{
//    bool not_good = false;
//
//    if (begin > end)
//    {
//        printf("%ld isn`t smaller than %ld.\n", begin, end);
//        not_good = true;
//    }
//    if (begin < low || end < low)
//    {
//        printf("values must be %ld or greater.\n", low);
//        not_good = true;
//    }
//    if (begin > high || end > high)
//    {
//        printf("values must be %ld or less.\n", high);
//        not_good = true;
//    }
//
//     return not_good;
//}


/* --------------------------------------------------------------------------------------------------------------------不对*/
//#include <stdio.h>
//char get_choice(void);
//void count(void);
//int main(void)
//{
//    int choice;
//
//    while ((choice = get_choice()) != 'q')
//    {
//        switch (choice)
//        {
//        case 'a': printf("buy low, sell high.\n");
//            break;
//        case 'b': printf("\a");       /* ANSI*/
//            break;
//        case 'c': count();
//            break;
//        default: printf("program error!\n");
//            break;
//        }
//    }
//    return 0;
//}


/* menuette.c -- 菜单程序 */
//#include <stdio.h>
//char get_choice(void);
//char get_first(void);
//int get_int(void);
//void count(void);
//int main()
//{
//    int choice;
//
//    while ((choice = get_choice()) != 'q')
//    {
//        switch (choice)
//        {
//        case 'a' : printf("buy ;ow, sell high.\n");
//            break;
//        case 'b': putchar('\a');              /* ANSI*/
//            break;
//        case 'c': count();
//            break;
//        default: printf("program error!\n");
//            break;
//        }
//    }
//    printf("bye.\n");
//
//    return 0;
//}
//
//void count(void)
//{
//    int n, i;
//
//    printf("count how far? enter an integer:\n");
//    n = get_int();
//    for (i = 1; i <= n; i++)
//        printf("%d\n", i);
//    while (getchar() != '\n')
//        continue;
//}
//
//char get_choice(void)
//{
//    int ch;
//
//    printf("enter the letter of your choice:\n");
//    printf("a. advice            b. bell\n");
//    printf("c. count             q. quit\n");
//    ch = get_first();
//    while ((ch < 'a' || ch > 'c') && ch != 'q')
//    {
//        printf("please respond with a, b, c, or q.\n");
//        ch = get_first();
//    }
//    return 0;
//}
//
//char get_first(void)
//{
//    int ch;
//
//    ch = getchar();
//    while (getchar() != '\n')
//        continue;
//
//    return ch;
//}
//
//int get_int(void)
//{
//    int input;
//    char ch;
//
//    while (scanf("%d", &input) != 1)
//    {
//        while ((ch = getchar()) != '\n')
//            putchar(ch);             /* 处理错误输出*/
//        printf("is not an integer.\nplease enter an ");
//        printf("integer value, such as 25, -178, or 3: ");
//    }
//
//    return input;
//}
//enter the letter of your choice :
//a.advice            b.bell
//c.count             q.quit
//a
//program error!
//enter the letter of your choice :
//a.advice            b.bell
//c.count             q.quit
//count
//program error!
//enter the letter of your choice :
//a.advice            b.bell
//c.count             q.quit
//two
//please respond with a, b, c, or q.
//d
//please respond with a, b, c, or q.
//a
//program error!
//enter the letter of your choice :
//a.advice            b.bell
//c.count             q.quit
//t
//please respond with a, b, c, or q.
//q
//program error!
//enter the letter of your choice :
//a.advice            b.bell
//c.count             q.quit
//输入你选择的字母 :
//advice建议; bell铃声;
//C.count计数;
//一个
//程序错误!
//输入你选择的字母:
//advice建议; bell铃声;
//C.count计数;
//数
//程序错误!
//输入你选择的字母:
//advice建议; bell铃声;
//C.count计数;
//两个
//请回答a, b, c或q。
//d
//请回答a, b, c或q。
//一个
//程序错误!
//输入你选择的字母:
//advice建议; bell铃声;
//C.count计数;
//t
//请回答a, b, c或q。
//问
//程序错误!
//输入你选择的字母:
//advice建议; bell铃声;
//C.count计数;

/* letheadl.c*/
#include <stdio.h>
#define NAME "GIGATHINK, INC."
#define ADDRESS "101 megabuck plaza"
#define PLACE "megapolis, CA 94904"
#define WIDTH 40

void starbar(void);     /* 函数原型*/

int main(void)
{
    starbar();
    printf("%s\n", NAME);
    printf("%s\n", ADDRESS);
    printf("%s\n", PLACE);
    starbar();            /* 使用函数*/

    return 0;
}

void starbar(void)              /* 定义函数*/
{
    int count;

    for (count = 1; count <= WIDTH; count++)
        putchar('*');
    putchar('\n');
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值