1.1 Function of the algorithm: guessing Price game

Source: Internet
Author: User

Recently in C language Network learning C language and algorithms, these essays as notes to facilitate their own research review

Guess Price Game introduction:

First show a product priced at 999 yuan, the participants to guess the price of this product. In the process of guessing the price, the host will give the "high" or "low" prompt according to the price given by the participants.

1#include <stdio.h>2 intMain ()3 {4      intOldprice,price=0, i=0;5printf"Please first set the real price of the product:");6scanf"%d",&oldprice);7System"CLS");8printf"Please enter the price of the trial guess: \ n");9       while(oldprice!=Price )Ten      { Onei++; Aprintf"participants:");  -scanf"%d",&Price ); -printf"Moderator:") ; the         if(price>Oldprice) -         { -printf"high, \ n.");  -         } +         Else if(price<Oldprice) -         { +printf"low, \ n."); A         } at         Else -         { -printf"Congratulations, you're right, the product belongs to you.!\n\n you have tried to guess%d times. \ n", i); -         } -      } - getch (); in      return 0;  -}

1.1 Function of the algorithm: guessing Price 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.