자유게시판

아직도 고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
    넵~ 양의정수(자연수)들의 평균을 계산하는 매우 기초적인 프로그래밍입니다~ ㅎㅎ;;

  1. 아방스 게시물 · 댓글 작성 규칙 (최근 수정일 2015.11.25)

    Date2012.07.17 Category공지 By완폐남™ Views47405
    read more
  2. DLC 2개 구입

    Date2015.06.20 Category잡담 Byjindou Views155
    Read More
  3. DK 드립을 쳐볼께요

    Date2010.08.11 Category잡담 By아게하 Views463
    Read More
  4. DJ MAX Technica= First Kiss

    Date2010.04.09 ByAssault Meteoric Star Views516
    Read More
  5. DIRCE -2-

    Date2015.05.23 Category제작 일지 ByTwinJ Views119
    Read More
  6. DIRCE -1-

    Date2015.05.17 Category제작 일지 ByTwinJ Views128
    Read More
  7. Dialog Extractor (알만툴 대사 텍스트 추출 및 변환)

    Date2014.01.14 Category제작 영상 ByAltusZeon Views4107
    Read More
  8. Dialog Extractor (?)

    Date2014.01.16 Category제작 일지 ByAltusZeon Views1653
    Read More
  9. deviantART의 대두꼬마 만들기 툴로...

    Date2014.12.25 Category잡담 ByBunny_Boy Views263
    Read More
  10. DESTIN 온라인 애니메이션 테스트

    Date2011.02.07 Category잡담 ByMania? Views324
    Read More
  11. Ddos 좀비pc인지 아닌지 확인하기

    Date2009.07.08 By아기공군둘리 Views647
    Read More
  12. dbrbgus님의 자살?

    Date2010.06.11 Category잡담 By노력쟁이 Views434
    Read More
  13. dayz 2d 로 만들어볼 생각인데 여려분의 의견은요?

    Date2013.01.28 Category제작 일지 ByJinJin Views1393
    Read More
  14. D.A캐릭터 미리보기

    Date2012.12.08 Category제작 스샷 By하늘바라KSND Views1230
    Read More
  15. D.A 시나리오 담당 몇 마디

    Date2012.11.21 Category제작 영상 By하늘바라KSND Views1200
    Read More
  16. D-Blue Days 평가요청글 삭제됐네요...

    Date2013.09.08 Category잡담 ByRoam Views1047
    Read More
  17. D-18,복귀예고

    Date2010.10.31 ByLuxmea Views561
    Read More
  18. D-17발자취

    Date2010.11.01 Category잡담 ByLuxmea Views322
    Read More
  19. D-16 수능의압박

    Date2010.11.02 Category잡담 ByLuxmea Views313
    Read More
  20. D-16 :: 91년생 멸망의 날... 얼마 남지 않았군(?).

    Date2009.10.27 Category잡담 ByMania Views908
    Read More
  21. D-15

    Date2010.11.03 Category잡담 ByLuxmea Views307
    Read More
목록
Board Pagination Prev 1 ... 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 ... 756 Next
/ 756