U E D R , A S I H C RSS

마름모출력/임다찬

No older revisions available

No older revisions available



ver.1
~cpp
#include <stdio.h>
int main(void){
	char ma;
	int k,i,j,byun;
	int max;

	printf("패턴입력 : "); scanf("%c",&ma);
	printf("변의 길이 입력 : "); scanf("%d",&byun);

	for(i=1;i<=byun;i++){
		for(k=byun;k>i;k--) 
			printf(" ");
		max=0;
		for(j=1;j<i+i;j++){
			printf("%c",ma);
			max++;
		}
		printf("\n");
	}
	for(i=0;i<byun-1;i++){
		for(k=0;k<=i;k++)
			printf(" ");
		for(j=i+i;j<max-2;j++)
			printf("%c",ma);
		printf("\n");
	}

	return 0;
}
----
ver.2
~cpp
#include <stdio.h>
int main(void){
	
	int i,j,k;
	int B_length;
	char pattern;

	printf("패턴입력 : "); scanf("%c",&pattern);
	printf("변의 길이 입력 : "); scanf("%d",&B_length);

	for(i=0;i<B_length;i++){
		for(k=1;k<B_length-i;k++) printf(" ");
		for(j=1;j<=2*i+1;j++) printf("%c",pattern);
		printf("\n");
	}
	for(i=0;i<B_length-1;i++){
		for(k=0;k<=i;k++) printf(" ");
		for(j=1;j<=(2*B_length-3)-2*i;j++) printf("%c",pattern);
		printf("\n");
	}	
	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:24
Processing time 0.0203 sec