DesignAssembler

備忘録に近い

STAP細胞を探すプログラム

かなり前に話題になったやつです。今更です。クソくだらないやつです。

#include<stdlib.h>
#include<stdio.h>
#include<time.h>
#include<string.h>

int main(void){

  int j,c;
  c=0;
  int i;
  char cell[4];
  srand((unsigned)time( NULL ));

    while(strcmp(cell,"STAP")!=0){
      for(i=0;i<4;i++){
	  cell[i] = 'A' + (rand() % 26);
      }
    cell[i] = '\0';
	if(strcmp(cell,"STAP") == 0){
		j=1;
        }
    printf(cell);
    printf("細胞 ");
    c++;
  }
  if(j==1){
        printf("%d",c);
        printf("回目の検証により");
        printf("STAP細胞が見つかりました\n");
  }
  return 0;
}


訂正 2/17 23:15
20行目はj=!;ではなくj=1;でした。ご指摘大変ありがとうございました。

f:id:hyottokoaloha:20150217191523p:plain