์๋๋ quizmachine.c ํ์ผ์ด๋ค.
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define DELAY 5
int main(){
srand(time(NULL));
int random1 = 0; //์ซ์1
int random2 = 0; //์ซ์2
int result = 0; //๊ฒฐ๊ณผ
time_t t1, t2; //์๊ฐ1, ์๊ฐ2
printf("Answer the 20 questions, then you can get a flag\n");
for (int i=0; i<20; i++){ //20๋ฒ ๋ฐ๋ณต
time(&t1);
random1 = rand() % 101; //์ซ์1 ๋๋ค
random2 = rand() % 101; //์ซ์2 ๋๋ค
printf("%d + %d = \n",random1,random2);//์ซ์ ๋๊ฐ๋ฅผ ๋ํด์ ํ๋ฆฐํธ
scanf("%d",&result); //๊ฒฐ๊ณผ๋ฅผ ์
๋ ฅ๋ฐ๋๋ค
time(&t2);
if(difftime(t2,t1)>DELAY){ //t1๋ถํฐ t2 ์ฐจ์ด๊ฐ 5๋ณด๋ค ํฌ๋ฉด
printf("time out!!!!!");//time out!!!!!
return 0;
}
else if(result!=random1+random2){ //์ค๋ต์ด๋ฉด
printf("wrong!!!\n"); //Wrong!!!
return 0;
}
}
printf("Success!!!\n"); //20๋ฒ ๋๋๋ฉด ์ฑ๊ณต
}

ํ์ด์ฌ ์ฝ๋๋ฅผ ์์ฑํ๋ค.

c ํ์ผ์ ์คํ ํ์ผ๋ก ๋ณํํ๋ค.


์ฑ๊ณต ๋ฉ์์ง๊ฐ ๋ฌ๋ค.
'๐ ๋ณด์ยท์ทจ์ฝ์ > ๐ธ์์คํ ยท์ด์์ฒด์ ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| [dreamhack] pwnable fd (0) | 2022.08.14 |
|---|---|
| buffer overflow์ ์ดํด (0) | 2022.08.14 |
| nc ๋ช ๋ น์ด ์ฌ์ฉ๋ฒ (0) | 2022.08.12 |
| [ubuntu] SSH ์ ์ ์ค์ต (0) | 2022.08.12 |
| File Descriptor (0) | 2022.08.12 |