U E D R , A S I H C RSS

새싹교실/2011/AmazingC/과제방 (rev. 1.8)

새싹교실/2011/AmazingC/과제방


과제 1.

이가희 과제제출!!

1.
#include <stdio.h>

int main()
{
	int star, row1, row2, blank;

	for(row1=7;row1>0;row1--) {
		for(star=0;star+row1>0;star--) {
			printf("*");
		}
		for(blank=0;blank<-2*row1+15;blank++) {
			printf(" ");
		}
		for(star=0;star+row1>0;star--) {
			printf("*");
		}
		printf("\n");
	}

	for(row2=0;row2<6;row2++) {
		for(star=0;star<row2+2;star++) {
			printf("*");
		}
		for(blank=0;blank<-2*row2+11;blank++) {
			printf(" ");
		}
		for(star=0;star<row2+2;star++) {
			printf("*");
		}
		printf("\n");
	}
	return 0;
}

//맨 첫 줄이랑 맨 마지막 줄 * 13개 만드는 건 알 거 같으면서도 모르겠네요ㅜㅜ


2.
#include <stdio.h>

int main()
{
	int star,blank,row;

	//part 1
	printf("           *\n");

	//part2
	for(row=1;row<=4;row++)
	{
		for(blank=1;blank+row<=10;blank++) printf(" ");
		printf("**");
		for(blank=1;blank<=2*row-1;blank++) printf(" ");
		printf("**\n");
		if(row==4) {
			for(blank=1;blank<=7;blank++) printf("*");
			for(blank=1;blank<=2*row+1;blank++) printf(" ");
			for(blank=1;blank<=7;blank++) 
			{
				printf("*");
				if(blank==7) printf("\n");
			}
		}
	}

	//part3
	for(row=1;row<=3;row++)
	{
		for(blank=1;blank<=2*row-1;blank++) printf(" ");
		printf("**");
		for(blank=1;blank<=21-4*row;blank++) printf(" ");
		printf("**\n");
	}

	//part4
	for(row=1;row<=2;row++)
	{
		for(blank=1;blank<=-2*row+5;blank++) printf(" ");
		printf("**");
		for(blank=1;blank<=9+4*row;blank++) printf(" ");
		printf("**\n");
	}

	//part5
	for(row=4;row>=1;row--)
	{
		if(row==4)
		{
			for(star=1;star<=7;star++) printf("*");
			for(blank=1;blank<=2*row+1;blank++) printf(" ");
			for(star=1;star<=7;star++) {
				printf("*");
				if(star==7) printf("\n");
			}
		}
		for(blank=1;blank+row<=10;blank++) printf(" ");
		printf("**");
		for(blank=1;blank<=2*row-1;blank++) printf(" ");
		printf("**\n");
	}

	//part6
	printf("           *\n\n");
	return 0;
}

//아 레알 조잡한거 같아여...ㅠㅠ
//쉽게 짤수 없을까여..ㅠㅠ

3.
#include <stdio.h>

int main()
{
	int front, back, result;

	for(front=1;front<=9;front++) {
		for(back=1;back<=9;back++) {
			result=front*back;
			printf("%dx%d=%d\n",front,back,result);
		}
		printf("\n");
	}

	return 0;
}

4.
// 369게임 출력하는 프로그램 만들기

#include <stdio.h>

int main()
{
	int a,b=1;

	a=1;
	printf("%d\n",a);
	a++;
	while(b<10) {                  //무한까지 안가게 하기 위한.. 30미만으로만 찍기..
		if(a==3*b) {
			printf("clap!\n");
			b++;
			a++;
		} else {
			printf("%d\n",a);
			a++;
		}
	}
	return 0;
}

박지호 과제제출

1.
#include <stdio.h>

int main()
{
	int i,j,k;
	for(i=0;i<=6;i++){
		if (i==0){
			for(j=1;j<=13;j++) printf("*");
			printf("\n");
		}
		else{
			for(j=1;j<=7-i;j++) printf("*");
			for(k=1;k<=2*i-1;k++,j++) printf(" ");
			for(;j<=13;j++) printf("*");
			printf("\n");
		}
	}
	for(i=5;i>=0;i--){
		if (i==0) {
			for(j=1;j<=13;j++) printf("*");
			printf("\n");
		}
		else{
			for(j=1;j<=(13-(2*i-1))/2;j++) printf("*");
			for(k=1;k<=2*i-1;k++,j++) printf(" ");
			for(;j<=13;j++) printf("*");
			printf("\n");
		}
	}

	return 0;

}

2.
#include <stdio.h>

int main()
{
	int r,s,b;
	r=1;
	while(r<=5){
		if(r==1){
			for(b=1;b<=11;b++) printf(" ");
			printf("*\n");
		}
		else if(r<=4){
			for(b=1;b<=11-r;b++) printf(" ");
			for(s=1;s<=2;s++) printf("*");
			for(b=1;b<=2*r-3;b++) printf(" ");
			for(s=1;s<=2;s++) printf("*");
			printf("\n");
		}
		else{
			for(s=1;s<=8;s++) printf("*");
			for(b=1;b<=7;b++,s++) printf(" ");
			for(;s<=23;s++) printf("*");
			printf("\n");
		}
		r++;
	}
	r=1;
	while(r<=3){
		for(b=1;b<=2*r-1;b++) printf(" ");
		for(s=1;s<=2;s++) printf("*");
		for(b=1;b<=17-4*(r-1);b++) printf(" ");
		for(s=1;s<=2;s++) printf("*");
		printf("\n");
		r++;
	}
	r=1;
	while(r<=3){
		if(r<=2){
			for(b=1;b<=4-(2*r-1);b++) printf(" ");
			for(s=1;s<=2;s++) printf("*");
			for(b=1;b<=13+4*(r-1);b++) printf(" ");
			for(s=1;s<=2;s++) printf("*");
			printf("\n");
		}
		else{
			for(s=1;s<=8;s++) printf("*");
			for(b=1;b<=7;b++,s++) printf(" ");
			for(;s<=23;s++) printf("*");
			printf("\n");
		}
		r++;
	}
	r=1;
	while(r<=4){
		if(r==4){
			for(b=1;b<=11;b++) printf(" ");
			printf("*\n");
		}
		else{
			for(b=1;b<=6+r;b++) printf(" ");
			for(s=1;s<=2;s++,b++) printf("*");
			for(;b<=15-r;b++) printf(" ");
			for(s=1;s<=2;s++) printf("*");
			printf("\n");
		}
		r++;
	}
	return 0;
}

3.
#include <stdio.h>

int main()
{
	int n,m;
	
	for(n=2;n<=9;n++){
		for(m=1;m<=9;m++) printf("%d x %d = %d\n", n, m, (n*m));
		printf("\n");
	}

	return 0;

}

4.
#include <stdio.h>

int main()
{
	int r;
	r=1;
	while(r<=29){
		if((r%10)%3==0){
			if(r%10!=0) printf("¦\n");//한글로 "짝"이라 썼는데 제눈에만 이상하게 보이는건지 모르겠습니다...복사해도 저데론데 실행하면 제데로 나옵니다(?)
			else printf("%d\n", r);
		}
		else printf("%d\n",r);
		r++;
	}
	return 0;
}
//30미만이라 짧게 끝난듯...

-ㅇㅇ 내가 원래 4번은 30미만까지만 하라고 할려 했는데 안적었나보네 ㅋㅋ-신기호

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:41
Processing time 0.0236 sec