자유게시판

아직도 고1때 작성한 소스파일이 남아있었을 줄이야....................ㅋㅁㅋ;;
옛날 기억이 새록새록~>ㅁ<
( 고1때 직접 작성한 것이기에, 영어 오타나 오기[誤記]가 있을지도 모릅니다;; )



// Program 2 : Read(Input) values and Calculate Average
// sentinel value is -1
#include <stdio.h>

// function main begins program execution
int main ( void ) {
// define variables
int i; // input count
int value;
int sum;
float average; // average is floating-point number

// initialize
i = 0 ;
sum = 0 ;

// program introduction
printf("*******************************************************************************\n");
printf("Program Introduction\n");
printf("*******************************************************************************\n");
printf("This program calculate integers average.\n");
printf("Do not enter zero or negative value. (Use only positive integer.)\n");
printf("If you enter value for -1, the input phase is end\n");
printf("and result(average) will be come out.\n");
printf("*******************************************************************************\n\n");

// first read value
printf("Input Value : ");
scanf("%d", &value);

// sentinel value is -1 >>> if value is -1, end input 
// error case 1 >>> if value is -1 and i is 0, print error message 1
// error case 2 >>> if value is not legitimate (zero or negative except -1), print error message 2
while ( value >= 0 ) {
sum += value ; // add value to sum
++i ; // increment count

// next read value
printf("Input Value : ");
scanf("%d", &value);
} // end while

/********************************* termination conduct *********************************/

/***** error case 1 *****/
if ( ( value == -1 ) && ( i == 0 ) ) { 
printf("\n[ERROR 1] You didn't input value\n"); // print error message 1
} // end if

/***** error case 2 *****/
else if ( value != -1 ) { 
printf("\n[ERROR 2] Input Error - Don't input negative or zero\n"); // print error message 2
} // end else if

/***** no error *****/
else { 
// calculate average
average = (float)sum / i ;

// print result(average) - precision is .2
printf("\nAverage is %.2f\n\n", average);
} // end else

return 0; // terminate program successfully
}

Who's 미루

?

< 제작한 게임 >

- 피그렛 (Piglet) [완성] : 링크 내림

- 파라딜루전 (Paradelusion) [미완성] : 링크 내림

- 주인잃은 공책 [완성] : http://avangs.info/1090264


< 연구실 홈페이지 >

http://mirulab.xo.st/


< 아방스 게임 실황 방송국 >

http://afreeca.com/miru3137

Comment '4'
  • ?
    TheEK 2013.02.02 20:40
    저에겐 그저 머~~~언 안드로메다 ... ㅠ
  • ?
    미루 2013.02.02 20:52
    안드로메다- ㅋㅁㅋ;;
  • profile
    하늘바라KSND 2013.02.02 21:48
    평균계산기?!
  • ?
    미루 2013.02.02 22:19
    넵~ 양의정수(자연수)들의 평균을 계산하는 매우 기초적인 프로그래밍입니다~ ㅎㅎ;;

List of Articles
분류 제목 글쓴이 날짜 조회 수
공지 아방스 게시물 · 댓글 작성 규칙 (최근 수정일 2015.11.25) 17 file 완폐남™ 2012.07.17 40615
제작 영상 [쯔꾸르 공포스릴러게임] 새크리파이스 짧은 영상 25. 2019.08.13 115
제작 영상 [2k3액알 던파] 머크우드 거의 다만들어 갑니다. (전체개발 8%) MakerAki 2019.08.14 95
잡담 며칠 전에 RPG MAKER MV를 샀습니다. 2 커블 2019.08.16 135
제작 영상 싱글 던파 (전격의 키놀 공격패턴) 1 MakerAki 2019.08.17 183
잡담 시그마 기자의 정리 파일 RPG란무엇인가? 2019.08.22 91
잡담 (경기게임아카데미 오픈세미나) <마녀의 샘> 글로벌 진출 성공기 허밍 2019.08.22 51
잡담 영 이거 제작이 난항이네요 2 omote23 2019.08.22 131
제작 영상 [2k3 이벤트 액션알피지] DNF 스킬 시스템 MakerAki 2019.08.24 70
잡담 안녕하세요 무림인 러브와 하이엘프 키우기를 제작 중 인 H.A.C입니다 HamelnAndCompany 2019.08.25 90
잡담 안녕하세요 하멜른 입니다. 이번에 하이엘프 키우기의 캐릭터 디자인을 교체했습니다 HamelnAndCompany 2019.08.30 48
잡담 안녕하세요 하멜른 입니다. 이번에 하이엘프 키우기의 캐릭터 디자인을 교체했습니다 HamelnAndCompany 2019.08.30 100
제작 영상 이벤트 액알 인벤토리 시스템 (일부 구현완료) 2 MakerAki 2019.09.07 154
잡담 렌코쨩 > 우치하 사구메 닉변 슈필러 2019.09.08 99
발표 (경기게임아카데미) 해외 및 국내 연사들의 글로벌 컨퍼런스! 유명기업 연사들이 한자리에! 허밍 2019.09.18 192
제작 영상 게임제작 과정과 간단한 팁을 보여주는 유튜브 채널을 오픈했습니다. 2 카르와푸딩의아틀리에 2019.09.28 114
막장 석달에 한번은 접속이 안되는 듯 1 무명시절 2019.10.04 100
잡담 (경기게임아카데미) 인디게임으로 글로벌에서 살아남기 허밍 2019.10.07 32
잡담 알만툴 디스코드 채팅방 홍보!! file 분필갈매기 2019.10.07 106
잡담 충청권(대전) 인디게임팀 소모임방을 만들었습니다 마트조아시카형 2019.10.13 48
제작 영상 [2k3 액알던파] 제작빈도 (시스템:70%) (스토리,던전: 14 or 17 %) 1 MakerAki 2019.10.15 112
목록
Board Pagination Prev 1 ... 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 ... 755 Next
/ 755