1. 程式人生 > >saw(獲取隨機數)

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編譯器下執行,待究。。。