#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main(){
float moneyAll,redbag;
int count,i;
do{
printf("输入红包金额(0~200元):");
scanf("%f",&moneyAll);
}while(moneyAll<0||moneyAll>200);
do{
printf("输入红包个数:");
scanf("%d",&count);
}while(count>moneyAll*100);
getchar();
srand(time(NULL));
printf("恭喜发财!按回车键抢红包!\nReady!Go!\n");
for(i=0;i<count;i++)
{ getchar();
if(i==count-1)
printf("红包金额 %6.2f 元\n\n红包已经抢光!\n",moneyAll);
else
{
redbag=(float)((rand()%((int)(moneyAll*100)/(count-i)*2)+1))/100;
printf("红包金额 %6.2f 元",redbag);
moneyAll-=redbag;
}
}
getchar();
return 0;
}
本文来源:https://www.wddqw.com/doc/ef0b1a49effdc8d376eeaeaad1f34693daef10fb.html
正在阅读:
模拟抢红包程序01-01
五年级收心课教育01-01
残疾证01-01
Android手机Gmail账户设置01-01
第14课时教案(体育的系统质-政治功能)01-01
期中总结01-01
关于「~ておく」用法的一些补充01-01
表示抬头向上看的四字词语01-01
你比划我猜成语作文700字01-01