看商品猜價格的游戲


#include <stdio.h>
int main(void){
	int realPrice, price=0, i=0;
	printf("親,請輸入商品的真實價格:");
	scanf("%d",&realPrice);
	system("cls");
	printf("請嘗試輸入您認為的價格:\n");
	while(realPrice != price){
		i++;
		printf("參與者:");
		scanf("%d",&price);
		printf("主持人:");
		if(price > realPrice){
			printf("您猜的價格高了\n");
		}
		else if(price < realPrice){
			printf("您猜的價格低了\n");
		}
		else{
			printf("恭喜,您猜對了!\n\n您一共猜了%d次",i);
		} 
	}
	getch();
	return 0;
} 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM