博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C语言之二分猜数字游戏
阅读量:4342 次
发布时间:2019-06-07

本文共 491 字,大约阅读时间需要 1 分钟。

#include <stdio.h>

#include <windows.h>
#include<string.h>
int main()

{

int oldprice, price = 0, i = 0;

printf("请首先设置商品的真实价格:");

scanf("%d", &oldprice);

system("cls");

printf("请输入试猜的价格:\n");

while (oldprice != price)

{

i++;

printf("参与者:");

scanf("%d", &price);

printf("主持人:");

if (price>oldprice)

{

printf("高了\n");

}

else if (price<oldprice)

{

printf("低了\n");

}

else

{

printf("恭喜你,答对了,该商品属于你了!\n\n你一共试猜了%d次.\n", i);

}

}

getchar();

return 0;

}

转载于:https://www.cnblogs.com/gcter/p/5743182.html

你可能感兴趣的文章
react.js
查看>>
P1313 计算系数
查看>>
NSString的长度比较方法(一)
查看>>
Azure云服务托管恶意软件
查看>>
My安卓知识6--关于把项目从androidstudio工程转成eclipse工程并导成jar包
查看>>
旧的起点(开园说明)
查看>>
生产订单“生产线别”带入生产入库单
查看>>
crontab导致磁盘空间满问题的解决
查看>>
java基础 第十一章(多态、抽象类、接口、包装类、String)
查看>>
Hadoop 服务器配置的副本数量 管不了客户端
查看>>
欧建新之死
查看>>
自定义滚动条
查看>>
APP开发手记01(app与web的困惑)
查看>>
笛卡尔遗传规划Cartesian Genetic Programming (CGP)简单理解(1)
查看>>
mysql 日期时间运算函数(转)
查看>>
初识前端作业1
查看>>
ffmpeg格式转换命令
查看>>
万方数据知识平台 TFHpple +Xpath解析
查看>>
Hive实现oracle的Minus函数
查看>>
秒杀多线程第四篇 一个经典的多线程同步问题
查看>>