자유게시판

아직도 고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 41182
잡담 테라리아 서버홍보 [신규케릭터만 가능][한글패치][야생] 1 테라리아죽돌 2012.10.08 1838
잡담 謹賀新年 送舊迎新 陽春方來 新年賀禮 新年祝賀 3 MANIA 2012.01.01 1838
잡담 컨스로 간단히 만든 본격 불뿜기 5 file 비극ㆍ 2012.02.17 1837
제작 스샷 rpg2003 에뮬을 안드용으로 만들고 있습니다 10 file morica 2013.05.26 1836
잡담 나도 어디서 주운 17금 한번 슬쩍. 4 Evangelista 2009.11.29 1835
잡담 요즘 아방스에 들어오는 사람들이 줄어든것 같음 3 강고리 2012.03.17 1834
잡담 쿼터뷰 빡세네요 8 Evangelista 2009.08.15 1833
가입 허허..어이가없어서 9 아방이 2008.01.26 1832
가입 이번에 아방스에 새로들어온 신입입니다 4 file 안티나유키 2012.02.18 1828
잡담 쓰려다 망한 도트 1 file 알중: 2012.01.09 1828
설문 [ 중요한 팁 ] 자료 저장시... 10 JEWAPPI 2010.06.26 1826
잡담 으아으ㅏㅇ아ㅣ잉! 캐릭터 도터가 필요한 시점. 16 Lighna 2012.04.14 1823
잡담 쯔꾸르 팬분들 필독! 14 Timey 2013.12.23 1821
가입 안녕하세요~ 1 해피론 2008.01.27 1821
잡담 게임을 전체화면 실행시, 화면 무한 깜빡임 문제가 발생합니다.. 해결방법있을까요 ㅠㅠ 2 걸음마 2014.04.18 1820
잡담 개인적인 느낌이랄까..? 2 Photoshop CS2 2009.10.08 1820
잡담 아음.. 너무 잔인한가? 8 file Lighna 2012.02.02 1819
잡담 [수정]절대강자 아방스님... 9 응가뿡뿡 2008.03.09 1819
[주의]피카츄 배구는 과학적이고 채계적인 사탄의 게임입니다. 9 아리안 2009.04.05 1818
제작 스샷 아방스에는 거의 처음이네요. 7 file 뮤바보 2013.01.24 1816
목록
Board Pagination Prev 1 ... 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 ... 755 Next
/ 755