中午吃啥 模拟抽奖小程序

背景:为了不向朋友问出中午去哪吃这种尴尬问题。。。。。。。
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', '大米食堂', '烤鸭小份', '盖浇饭', '米线', '牛肉面']))
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值