中午吃啥 模拟抽奖小程序

背景:为了不向朋友问出中午去哪吃这种尴尬问题。。。。。。。
c语言代码

#include <stdio.h>
#include <stdlib.h> //<stdlib.h>用于调用 rand(),
#include <time.h> //声明time 时间不可逆转一直在变
#include <Windows.h>  //<Windows.h> 用于清屏
#include <conio.h>  //<conio.h>  用按键用的
int main()
{
int num;
srand((unsigned)time(0)); 
	while (1)
	{
		if (!_kbhit())
	{ num = rand()%(999-100+1)+100; //rand()用法:rand()%(上限-下限+1)+下限
	printf("盖饭   3c   食堂   \n抽店中....\n");
	Sleep(10);              
	system("cls");	
	}        
	else break;		
	}
	printf("盖饭   3c   食堂: 今天吃");	
	if(num>=100&&num<=400) 
	printf("盖饭");
	else if(num>=401&&num<=700) 
	printf("3c");
	else
	printf("食堂"); 
	return 0;
}

在这里插入图片描述
在这里插入图片描述
python代码

import random
print(random.choice(['3c', '大米食堂', '烤鸭小份', '盖浇饭', '米线', '牛肉面']))
posted @ 2022-06-24 08:50  羽小兮  阅读(307)  评论(0)    收藏  举报