자유게시판

아직도 고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 47408
잡담 망할 MV 진짜 4 구슯 2018.06.10 262
잡담 [동아리] 대학생연합 게임제작 동아리 Bridge 신입 모집(~6/30) file 어데이드 2018.06.08 398
잡담 본업이 너무 바빠서 게임제작도 맘대로못하고 잠행인 2018.05.29 84
잡담 유니티로 쯔꾸르 제작하기 [강좌 - Part 0] 5 file 케이디 2018.05.28 459
잡담 스팀버전 알만툴은 한글 패치 안 되나요? 1 김초보 2018.05.28 188
잡담 창작 욕구는 넘치지만.... XPExpert 2018.05.15 119
잡담 안녕하세요 ~! 알만툴로 게임 제작하는 팀에 참여할때 궁금점이 있습니다. 4 러니 2018.05.11 111
잡담 넷플이던 NRPG던 한번 해보고싶은데 되는게없네요 YangMyunCreeper 2018.04.29 75
잡담 3dsmax로 MV 캐릭터칩 만들기 실험 2 file 책벌레공상가 2018.04.26 213
잡담 안녕하세요, 개발자 여러분! 5 가족같이 2018.04.23 182
잡담 특정컴에서 아방스 접속이 너무 느린데 1 파치리스 2018.04.17 177
잡담 오랜만입니다 4 file JACKY 2018.04.16 221
잡담 옛날 하나포스시절 게임을 찾습니다 p초로 2018.04.03 141
잡담 DR3AM 프로젝트를 진행중입니다 file BIGHEADCRUSHER 2018.03.26 82
잡담 댓글 알림이 안옵니다 3 파치리스 2018.03.25 120
잡담 노 사운드 게임 어떻다고 생각하세요? 6 비스뀌 2018.03.16 269
잡담 장기프로젝트 3개월차 2 file 봉지냥 2018.03.11 136
잡담 RPG Maker MV v1.5.2 베타 업데이트 안내 1 file 러닝은빛 2018.02.28 155
잡담 <Machtig> 텀블벅 프로젝트를 진행하게 되었습니다! file 제이버 2018.02.28 106
잡담 RMMV 1.6.0 버전이 나왔습니다. 러닝은빛 2018.02.22 144
목록
Board Pagination Prev 1 ... 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ... 457 Next
/ 457