c语言简单编程 求解答

问题描述

c语言简单编程 求解答

guess the number (1 points)
? Define a number between one and one hundred
? If a user input a number, the computer output “Too high!” or
“Too low!”
? If you guess the number in 6 tries, print “That’s Correct!” ? If not, print “Sorry, bye bye~”

解决方案

C语言编程求最小公倍数
用C语言编程求青蛙王子问题

解决方案二:

#define NUM 12
printf("I'm thinking of a number between and including 1 to 100
");
printf("Can you guess the number in 6 tries?
");
for( int i= 0;i < 6;++i)
{
printf("Enter guess number %d:",i+1);
int inputNum;
scanf("%d",&inputNum);
if( inputNum > NUM )
printf("Too high!
");
else if( inputNum < NUM )
printf("Too low!
");
else
{
printf("That's Corrent!
");
break;
}
}

解决方案三:

#include <stdio.h>
#include <time.h>

//生成一个1 - 100 的随机值
int GetRandNum(void)
{
    srand((unsigned int)time(0));

    return (rand()%100) + 1;
}

//猜测系统生成的随机数
void GuessSysRandNum()
{
    int a = GetRandNum();
    int i = 1;
    int b;
    while(i < 7)
    {
        printf("Enter guess number %d:", i);
        scanf("%d", &b);
        if(a > b)
        {
            printf("Too low!
");
        }
        else if(a < b)
        {
            printf("Too high!
");
        }
        else
        {
            printf("That's Correct!
");
            return;
        }
        i++;
    }
    printf("Sorry, bye bye ~
");
}

int main(void)
{
    GuessSysRandNum();

    return 0;
}
时间: 2024-09-03 23:37:41

c语言简单编程 求解答的相关文章

c语言初级编程 求解答

问题描述 c语言初级编程 求解答 Write a program that adds two numbers using the three functions ? Function 1 : int main(void) ? Function 2 : int Input(void) ? Function 3 : int Add(int i, int j) Ex)(例子) Input two numbers : 3 4 Results : 7 解决方案 图和文字不相符 以你的文字为准: #incl

c语言-数据操作的问题,,C语言,炒鸡简单,求解答

问题描述 数据操作的问题,,C语言,炒鸡简单,求解答 #include#includeint main(){ int abc; scanf(""%d %d %d""&a&b&c); //double abc; //scanf(""%f %f %f""&a&b&c); if(a==b&&b==c) printf(""等边三角形n"&qu

c语言-C语言函数问题求解答,求大神

问题描述 C语言函数问题求解答,求大神 输入2个整数,分别将其逆向输出,要求定义并调用函数fun(n),它的功能是返回n的逆向值?例如,fun(123)的返回值是321 函数出什么问题了,输出错了 #include #include int fun(int x); int main(void) { int m1,m2; printf("Input m1: "); scanf("%d",&m1); printf("Input m2: ");

文件-c语言 火车票管理系统 求解答

问题描述 c语言 火车票管理系统 求解答 运行后不能添加,删除,修改,查询班次到文件 可是文件是已经建好有数据的,查询时只显示一条然后就非正常退出了,我怀疑是最后链表做的有问题函数read()可是就是找不到哪错了,希望有哪位朋友可以解答一下, #include #include #include #include #include #include typedef struct Tickets { char num; char time[8]; char starts[8]; char ends

C语言基础问题求解答,运算符

问题描述 C语言基础问题求解答,运算符 if((b[i]=='a')||(b[i]=='e')||(b[i]=='i')||(b[i]=='o')||(b[i]=='u')) 可以写成下面的形式吗? if(b[i]==('a'||'e'||'i'||'0'||'u')) 解决方案 不可以的,会先判断括号里面的.你用switch语句 解决方案二: 可以这么写 if (strstr("aeiou", b[i]) != null) ... 解决方案三: 参考http://blog.sina.

Spring MVC简单问题 求解答!!!!!

问题描述 Spring MVC简单问题 求解答!!!!! 参考下列代码: 传值问题,form内可以传.如何传值?通过a标签!对A标签需要如何修改? <form action="in.do"> <input type="text" id="a" name="name"/> <input type="submit" value="OK"> </for

c语言简单编程

问题描述 c语言简单编程 Input array size N (1~20)Using Two-Dimensional array输入数组大小氮(1 - 20)二维数组 解决方案 楼上站着说话不腰疼.这道题只给思路,但是你那个最关键的思路就没给.我以为自己十分钟可以搞定这题,结果弄了一个小时...给出经过测试的C语言源码如下: #include ""stdio.h""#include ""stdlib.h""#define N

测试-关于windows多语言的疑问 求解答

问题描述 关于windows多语言的疑问 求解答 我干测试也有两年了,近日来一直被windows多语言的测试所困扰,公司有一款C/S软件,需要测试多语言,测试系统兼容性,大家都知道windows是可以装语言包的. 那么在不同版本的系统上也需要测多语言么,比如在win8上测了一遍,win10上还需要测试么?windows更新从win7起提出了多语言系统的概念,到后面每次升级都没有再提了,那么是不是可以认为从win7 到win8 win8.1 乃至现在的win10.在多语言上实现是一样的. 一直找不

opengl-OpenGL入门编程求解答 错误 4 error LNK2001: 无法解析的外部符号 _NtProcessStartup

问题描述 OpenGL入门编程求解答 错误 4 error LNK2001: 无法解析的外部符号 _NtProcessStartup 代码如下,从计算机图形学第三版完整抄下来的程序. 错误就是 4 error LNK2001: 无法解析的外部符号 _NtProcessStartup 求大神 #include #include #include void init(void) { glClearColor(1.0,1.0,1.0,0.0); //窗口背景颜色 glMatrixMode(GL_PRO