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