티스토리 뷰

헉!!/C언어

110330

권태성 2011. 3. 30. 11:28
728x90

 

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

 

int main(void)

{

        int num, i;

        int sum=0, max=0, min=200;

 

        srand(time(NULL));

 

        for(i=0; i<100; i++)

        {

               num=rand() % 101 + 100;

 

               if(num % 2 == 0)

               {

                       i--;

                       continue;

               }

 

               sum+=num;

               if(max < num)

               {

                       max = num;

               }

               if(min > num)

               {

                       min = num;

               }

 

               printf("%5d", num);

 

               if((i+1)%10==0)

               {

                       printf("\n");

               }

        }

        printf("\n총합은: %d\n", sum);

        printf("총평균은: %.2f\n", sum/100.0);

        printf("가장큰값은: %d\n", max);

        printf("가장작은값은: %d\n", min);

}

 

 

 

728x90

'헉!! > C언어' 카테고리의 다른 글

[C언어] 셀렉션 소팅 (selection sorting)  (0) 2011.03.30
Line Ending - CR+LF / LF / CR  (0) 2010.11.17