zoukankan      html  css  js  c++  java
  • C实现猜数字

    一、概述

      案例:使用C语言实现猜数字的功能。控制台会提是“大了”,“小了”,“猜对了”

      目的:记录C的学习过程,并无其他实际含义

    二、示例代码

    #include <iostream>
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    
    
    using namespace std;
    
    int main(int argc, char const *argv[])
    {
    	/* code */
    	srand(time(NULL));//随机数种子
    	int n = 0;
    	int num = rand()%100;//生成随机数字
    	cout << "rand num is "<< num<<endl;
    	for(;;){
    		cout<< "please input num:"<<endl;
    		scanf("%d",&n);
    		if(n<num){
    			cout << "Is too litter"<<endl;
    		}else if(n>num){
    			cout << "Is too biger"<<endl;
    		}else{
    			cout << "Is very good"<<endl;
    			break;
    		}
    
    
    	}
    	cout << "I am is "<< num<<endl;
    	return 0;
    }
    

      

  • 相关阅读:
    daper
    存储过程事务
    dengluzhucehaiyouxianshiMVC
    遍历加监听
    类的操作
    轮播图
    定时器的应用(三)
    定时器的应用(二)
    定时器的应用(一)
    延时调用
  • 原文地址:https://www.cnblogs.com/tony-yang-flutter/p/15386044.html
Copyright © 2011-2022 走看看