U E D R , A S I H C RSS

마름모출력/이재경

~cpp


#include <stdio.h> 

int main() 
{  
     
    int b,r,a; 
	int n;
	
	printf("홀수인 층수를 입력하시오\n");
	scanf("%d",&n);
       
		for(r=0;r<(n+1)/2;r=r+1){ 
         
			for(b=0;b<(n+1)/2-r;b=b+1){ 
        
            printf(" "); 
			} 
			for(a=n/2;a<n/2+2*r+1;a=a+1){     
            printf("*"); 
             
             
        } 
         
        printf("\n"); 
         
         
    } 
	
		
    for(r=0;r<n/2;r=r+1){ 
             
            for(b=n/2-2;b<n/2+r;b=b+1){ 
                 
                printf(" "); 
            } 
             
            for(a=0;a<n-2*r-2;a=a+1){ 
                 
                printf("*"); 
            } 
             
            printf("\n"); 
             
             
        } 
     	
	
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2009-05-27 07:09:19
Processing time 0.1948 sec