saw(获取随机数)



Description

I want to play a game.

Up until now, you've simply sat in front of computers watching others cheer to solve their problems. Now I see you as a strange mix of someone apathetic. But mostly just pathetic. ‘Cause you haven’t solved all these problems, at least not this one. So are you going to watch yourself end your warm-up contest here today, or do something about it?

These are the rules. I have nothing in the input data. But you, you come up with a capital letter in your mind. Yes, that’s the very letter I want you to output.

Input

Nothing to input. But congratulations. You still have time.

Most people are so ungrateful to get ACs. But not you. Not anymore.

Output

Know that I'm not lying. Better hurry up. Output the capital letter in your mind.

Make your choice.

Sample Input

(nothing)

Sample Output

(a letter stated above)

HINT

这题wa了无数次,经大神指导终于明白了题目的意思,根据系统时间产生一随机数,并转化为字母,其中涉及到srand函数和rand函数;

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
main()
{
 srand( unsigned( time(0) ));
 int i=rand()%26;
 char a='a';
 a=a+i-32;
 printf("%c",a);
}

大神的指导:

zhuyi13:
用srand()获得随机数种子
然后int i=rand(time(NULL))%26;//获得一个0~25的随机数
char a='a';
a=a+i;
cout<<a<<endl;
因为time(NULL)获得的随机种子是根据系统时间来得到的
所以和后台获得的随机数回一样
还有一点这个程序不能再c编译器下运行,待究。。。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值