자유게시판

아직도 고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 132850
발표 자취방 입성~ 15 JACKY 2013.02.24 934
하아 ... 시간이 흐를 수 록 ... 12 TheEK 2013.02.24 1198
잡담 신입생들 시간표 24 file 미루 2013.02.24 930
잡담 프로그래밍 정말 잘하고싶네요 ㅠㅠ 7 Lighna 2013.02.23 1172
제작 영상 페이블러시 0.8제작현황[동영상포함] 5 펭블♡ 2013.02.23 1064
잡담 그래서 국산 알만툴 겜중에 늘 추천드리는 게 있습니다 15 Roam 2013.02.23 2849
제작 영상 지금 제작중인 탑뷰슈팅 7 개촙포에버 2013.02.23 977
RGSS2 Player 로여는게임의 배경소리가 자꾸뚝뚝끊기네요 2 rainblue37 2013.02.23 1295
막장 1세대 보컬로이드가 2세대 이후에 비해 자연스러움이 떨어진다만..... 4 Alkaid 2013.02.23 1483
막장 개인적으로 좋아하는 보컬로이드 곡 중 하나. 2 Alkaid 2013.02.22 1182
잡담 아무래도 육성미연시를 만들어야겠뜸 FNS키리토 2013.02.22 1143
잡담 으잉?! 이게 뭐시여... 온라인 게임 온리전? 23 하늘바라KSND 2013.02.22 1561
잡담 하..알바구하기 힘들다. 3 황금시계 2013.02.22 1169
잡담 데드 스페이스 3 클리어! (스포주의, 혈흔주의, 어리신 분들은 주의!) 16 file TheEK 2013.02.21 2162
잡담 우왕 겜메가 PSD도 먹히네요 11 개촙포에버 2013.02.21 1027
잡담 보컬로이드 시유 13 TheEK 2013.02.20 3011
잡담 The Mirror Lies를 클리어 후... 2 Alkaid 2013.02.20 1292
제작 스샷 헐........ 난이도가......... 'Piglet(피그렛) 베타(β)구역' 17 file 미루 2013.02.20 1159
막장 광고쟁이의 습격2- 댓글 도쟁이의 출현 2 하늘바라KSND 2013.02.19 1569
잡담 나 포인트 확인하고싶은데 어디서 봄? 2 개촙포에버 2013.02.19 1142
목록
Board Pagination Prev 1 ... 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 ... 759 Next
/ 759