자유게시판

아직도 고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 47407
잡담 모 게임의 일부 스크립트를 교체해 보면서... 1 Alkaid 2012.01.14 1876
잡담 아방스 업데이트를많이 하는 것 같음ㅋㅋ 4 L 2012.04.30 1876
잡담 우리집 컴들만 그런가 3 가와싸미 2012.01.19 1877
잡담 대화창에 캐릭터 그래픽 표시 답변 7 북극토끼 2014.07.19 1879
잡담 엘카르디아 오프닝 8 카르와푸딩의아틀리에 2009.09.02 1882
나도 목소리를 녹음해봤더니 역시 에바 1 file 카이온 2011.12.23 1882
제작 스샷 저의 로고와 캐릭칩 2 file 구름인간 2013.03.16 1882
설문 메인화면에 안뜨는 강좌들 왠지 섭섭해요 3 정체불명 2012.01.18 1887
발표 Valuable Guidance For Those Seeking Auto Maintenance And Routine maintenance ywareh 2019.02.12 1887
잡담 아방스님은 확인해주세요~ 4 은색바람 2012.04.12 1889
설문 여러분만이 알고있는 서브퀘스트를 써주세요! 19 질풍처럼 2010.11.16 1890
잡담 지금 Dark GDK 라이브러리로 게임을 만들까 하고 있습니다. 2 Saber 2010.01.05 1891
설문 누가 귀엽고 누가 이쁜건지 투표좀요 ㄷㄷㄷㄷ 12 file 톰소여동생 2012.03.03 1893
제작 스샷 도트를 잘 찍기 위해서! 18 file 윌허트 2013.05.03 1893
도트를 찍어보았으나 실패... 7 file 미루 2013.09.15 1894
제작 스샷 타이틀 완성~ 16 file 에뎀이 2014.07.07 1894
잡담 VX Ace RTP 용량이 커진 이유중 하나. 3 Alkaid 2011.12.15 1897
잡담 괴기 그림 이랑 몹 디자인 그려봄 4 file 잉여VICTIM 2013.04.24 1900
잡담 힘들게 구현한 두칸, 세칸짜리 몬스터 4 아르피쥐 2011.12.11 1902
잡담 흑흑 제발 도와주세요 파판 전투승리 효과음 찾고 있습니다. 3 욕쟁이스님 2010.12.18 1906
목록
Board Pagination Prev 1 ... 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 ... 756 Next
/ 756