U E D R , A S I H C RSS

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

새싹교실/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;
}

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

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