C language to write a simple game

Source: Internet
Author: User

  Sentiment: This is a starting point, I am a sophomore, but also this dish, just started to write games, this game is very simple, using random numbers to guess the size!

  

#include <stdlib.h> #include <stdio.h> #include <time.h>int main () {    int n;    int number;    Srand ((unsigned) time (NULL));    Number = rand ()%100;    printf ("Game starts!\n");    while (1) {        printf ("Please enter an integer between 1-100:");        scanf ("%d", &n);        if (n = = number) {            printf ("Congratulations you guessed it, the game is over.") \ n ");            break;        }        if (n > Number)            printf ("Big \n\n\n");        if (n < number)            printf ("Small \n\n\n");    }    return 0;}

  Note: I write this simple game just to start practicing the use of random numbers, I will play the game here, the algorithm and data structure of the code on the csdn over there, the next time to submit a Java to write the aircraft War and C + + version of the snake!!! ITCSC man can't confess!!! up!up!up!

The csdn:http://blog.csdn.net/empire_ing of the great Lord

C language to write a simple game

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.