#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
//随机函数(随机生成一个数字)
//5-10之间随机生成一个数字
//a-b (b-a+1)+a
int number = arc4random()%6+5;
printf("%d\n",number);
//刀塔
/*
随机到1 斧王
2 小黑
3 风行
4 尸王
5 剑圣
*/
//1-5
int heroNumber = arc4random()%5+1;
//1case后面要加大括号
//2不要拉掉break如果没写break会出现贯穿现象
//3多个case对应同一块内容
//4case的顺序是无所谓的
//5default可以删掉
switch (heroNumber) {
case 2:
case 1:
case 3:
{
printf("风行");
}
break;
case 4:
{
printf("尸王");
}
break;
case 5:
{
printf("剑圣");
}
break;
default:
break;
}
/*
1,洗衣服
2,做饭
3,拖地
4,LOL
*/
int number1 = arc4random()%4+1;
switch (number1) {
case 1:
{
printf("洗衣服");
}
break;
case 2:
{
printf("做饭");
}
break;
case 3:
{
printf("拖地");
}
break;
case 4:
{
printf("LOL");
}
break;
default:
break;
}
int number2 = 0;
printf("亲输入一个数字\n");
scanf("%d",&number2);
printf("number2 = %d\n",number2);
int a = 0;
while (a<number2) {
int result = arc4random()%6+5;
printf("%d\n",result);
a++;
}
return 0;
} |