Last active
August 29, 2015 14:02
-
-
Save yonta/6f264541071a3b047c38 to your computer and use it in GitHub Desktop.
はやりのランダムSTAP細胞
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <time.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#define ANS "STAP" | |
void rand_stap(char* buff){ | |
int i; | |
for(i=0; i<4; i++) | |
buff[i] = rand() % 26 + 65; /* from A(65) to Z(90) */ | |
} | |
int main(){ | |
int i=0, cond=1; | |
char buff[] = "0000"; | |
srand((unsigned)time(NULL)); /* init rand */ | |
while(strcmp(buff, ANS) != 0){ | |
i++; | |
rand_stap(buff); | |
printf("%s細胞", buff); | |
} | |
printf("%d回目で陽性かくにん!よかった\n", i); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment