자유게시판

아직도 고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 41177
잡담 게임만들다 약빨고있어요 1 아르피쥐 2011.12.09 1926
클럽박스의 정체! 조심하자! 5 독도2005 2008.05.15 1927
발표 캐릭터 레이더는 프리웨어가 아니었습니다 11 file 모쟁 2014.01.14 1930
잡담 그러게요.. 지금 vx ace 어떻게 쓰시나요 2 한담아 2012.01.03 1931
커...컴퓨터가 터졌어요... 5 zki 2012.03.07 1934
그러고보니 왜 에이스에는 음악가 캐릭이 없죠? 비비드 2012.02.19 1936
잡담 도쟁 다음에는 불법 엮인글 홍보쟁이가! 은색바람 2013.03.13 1936
잡담 가물가물한 기억 속 엔딩도 보지 못한 게임들 8 file 에뎀이 2014.03.14 1938
한달뒤면 컴퓨터강사자격증온다능!! 2 은색바람 2012.03.24 1939
우리집의 흔한 대화.TXT 7 개촙포에버 2012.05.08 1941
잡담 마인크래프트 멀티 총모드로 공성전 구상중 7 star211 2011.02.08 1942
잡담 잔랙에도 불구하고 신나게 카운터당하는분 2 Lighna 2012.02.05 1942
잡담 오늘 스승의 날이래요! 6 2012.05.15 1945
잡담 XAS 에 맞게 RPG Maker VX ACE 를 개조한다면~~~??? 16 file 미루 2013.01.18 1946
잡담 캐릭터 이미지만드실수잇는 스승을 구합니다. 1 Tmore 2012.02.03 1947
막장 뭐, 뭔일인겨 3 하늘바라KSND 2012.03.24 1947
잡담 난 솔직히 이쪽 그리는게 취향임.. 2 SCUD 2009.08.23 1948
막장 포팡이가 돌아왔닼ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ 10 슈팅스타* 2012.04.13 1948
막장 쯔꾸르 MV 모바일 포팅 된다는거... 3 파치리스 2015.10.25 1949
잡담 포토샵 cs3 키젠먹이는거 아시는분 안계시나요? 2 HeyCat 2010.01.15 1951
목록
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