내용으로 건너뛰기
PEL-Protocol Engineering Lab.
사용자 도구
등록
로그인
사이트 도구
검색
도구
문서 보기
이전 판
역링크
최근 바뀜
미디어 관리자
사이트맵
등록
로그인
>
최근 바뀜
미디어 관리자
사이트맵
추적:
c_rand_ext
이 문서는 읽기 전용입니다. 원본을 볼 수는 있지만 바꿀 수는 없습니다. 문제가 있다고 생각하면 관리자에게 문의하세요.
<code c> /* rand_ext.c: guess the number */ #include <stdio.h> /* printf, scanf, puts, NULL */ #include <stdlib.h> /* srand, rand */ #include <time.h> /* time */ int main(void) { int secret, guess; /* initialize random seed */ srand(time(NULL)); /* generate secret number between 1 and 10 */ secret = rand() % 10 + 1; do { printf ("Guess the number (1 to 10): "); scanf ("%d",&guess); if (secret < guess) puts ("The secret number is lower"); else if (secret > guess) puts ("The secret number is higher"); } while (secret != guess); puts ("Congratulations!"); return 0; } </code>
c_rand_ext.txt
· 마지막으로 수정됨: 2015/02/07 18:38 (바깥 편집)
문서 도구
문서 보기
이전 판
역링크
맨 위로