Skip to content

Instantly share code, notes, and snippets.

@yonta
Last active August 29, 2015 14:02
Show Gist options
  • Save yonta/6f264541071a3b047c38 to your computer and use it in GitHub Desktop.
Save yonta/6f264541071a3b047c38 to your computer and use it in GitHub Desktop.
はやりのランダムSTAP細胞
#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