
4个回答
展开全部
#include<iostream>
#include<ctime>
using namespace std;
int main()
{
srand((unsigned)time(NULL));
cout<<rand()%6+1<<endl;
return 0;
}
#include<ctime>
using namespace std;
int main()
{
srand((unsigned)time(NULL));
cout<<rand()%6+1<<endl;
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
int a;
a = rand()%6 + 1
a = rand()%6 + 1
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
可以使用rand函数,参考代码:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i, r;
srand(time(NULL));
for (i = 0; i < 20; ++i)
{
r = (rand() % 6) + 1;
printf("%d ", r);
}
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i, r;
srand(time(NULL));
for (i = 0; i < 20; ++i)
{
r = (rand() % 6) + 1;
printf("%d ", r);
}
return 0;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |