Presentation is loading. Please wait.

Presentation is loading. Please wait.

6장 연습 문제 풀이 학번 :04190021 이름 :조 재한.

Similar presentations


Presentation on theme: "6장 연습 문제 풀이 학번 :04190021 이름 :조 재한."— Presentation transcript:

1 6장 연습 문제 풀이 학번 : 이름 :조 재한

2 6.1 100에서 1000까지의 사이의 수에서 소수를 구하고 그 개수를 구하는 순서도를 작성하시오.
N = 100,1000, 1 Start P = 1, N, 1 count = 0 number= 0 Mode=N%P Mode=0 Write 소수 구하기 Yes Count++ count=2 Yes Write N Write소수의개수 =Number개 Number++ count = 0 End

3 #include <stdio.h>
main() { int count=0, number=0; int n,p,mode; printf("소수 구하기 \n"); for (n=100;n<=1000;n++) for (p=1;p<=n;p++) mode=n%p; if(mode==0) count++; } if(count==2) printf("%d은 소수이다!\n",n); number++; count=0; printf("소수의 개수= %d\n",number);

4 6.2 1에서 100까지의 수에서 약수의 개수가 5이상인 것을 모두 찾는 순서도를 구하시오.
N = 1,100, 1 Start P = 1, N, 1 count = 0 number= 0 Mode=N%P Mode=0 Write 약수 구하기 Yes Count++ Count>=5 Yes Write N Write 약수가 5개 이상 =Number개 Number++ count = 0 End

5 #include <stdio.h>
main() { int count=0, number=0; int n,p,mode; printf("소수 구하기 \n"); for (n=1;n<=100;n++) for (p=1;p<=n;p++) mode=n%p; if(mode==0) count++; } if(count>=5) printf("%d는 약수가 5개 이상이다.\n",n); number++; count=0; printf("약수가 5개 이상인 숫자의 개수= %d\n",number);

6 6.3 다음의 결과를 출력하는 순서도를 작성하시오. i = 1,9, 1 Write 구구단 구하기 j = 1, 9, 1
Start Write 구구단 구하기 i = 1,9, 1 j = 1, 9, 1 Write I x j = I * j End

7 #include <stdio.h>
main() { int i,j; printf("구구단\n"); for (i=1;i<=9;i++) for (j=1;j<=9;j++) printf("%d * %d = %d\n",i,j,i*j); }

8 ***** **** *** ** * 6.4 다음의 결과가 나오는 순서도를 작성하시오. P = 5,1, 1 N= 1, P, 1
Start ***** **** *** ** * P = 5,1, 1 N= 1, P, 1 Write * 줄바꾸기 End

9 #include <stdio.h>
main() { int p,k; for (p=5;p>=1;p--) for (k=1;k<=p;k++) printf("*"); printf("\n"); }

10 * *** ***** ****** ******** 6.4 다음의 결과가 나오는 순서도를 작성하시오. P = 1,9, 2
Start * *** ***** ****** ******** P = 1,9, 2 N= 5, 1, 1 Write * 줄바꾸기 End

11 #include <stdio.h>
main() { int n,p,mode,m,i; for (n=1;n<=9;n++) for (m=5;m>=1;m--) for (i=1;i<=m;i++) printf(" "); } mode=n%2; if(mode==1) for (p=1;p<=n;p++) printf("*"); printf("\n");

12 1 12 123 1234 12345 6.4 다음의 결과가 나오는 순서도를 작성하시오. P = 1,5, 1 N= 1, P, 1
Start 1 12 123 1234 12345 P = 1,5, 1 N= 1, P, 1 Write P 줄바꾸기 End

13 #include <stdio.h>
main() { int p,k; for (p=1;p<=5;p++) for (k=1;k<=p;k++) printf("%d",p); printf("\n"); }


Download ppt "6장 연습 문제 풀이 학번 :04190021 이름 :조 재한."

Similar presentations


Ads by Google