Luke'family

Luke's family

TimeLimit: 1 Second  MemoryLimit: 32Megabyte

Totalsubmit: 80  Accepted: 22 

Description

In the stars’ family, Luke only has seen his father andgrandfather. He really wants to know what his ancestors look like.We numbered Luke as the No.0 star. Luke’s father is No.1 star, andthe father of Luke’s father is No.2 star, and so on.
Luke looks like:
*
Luke’s father looks like:


   *
* * * *
 * * *
* * * *
   *

The father of Luke’s father looks like:


     *
     **
* * * * * * *
 * * * * * *
  * * * * *
 * * * * * *
* * * * * * *
     **
     *

Input

There are multiple test cases.
In each test case, the first line is an integer n(1<=n<=90).

Output

For each test case, first output a line “Case T:” T starts with 1.And then output what the No.n star looks like.

Sample Input

0
1
2
3

Sample Output

Case 1:
*
Case 2:
   *
* * * *
 * * *
* * * *
   *
Case 3:
     *
     **
* * * * * * *
 * * * * * *
  * * * * *
 * * * * * *
* * * * * * *
     **
     *
Case 4:
        *
       * *
      * * *
* * * * * * * * * *
 * * * * * * * * *
  * * * * * * * *
   * * * * * * *
  * * * * * * * *
 * * * * * * * * *
* * * * * * * * * *
      * * *
       * *
        *

Source

Luke


#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<string.h>
#include<stdlib.h>
#include<math.h>

using namespacestd;
int main(){
    int n,i,j,k,s,t,T=1;
    while(~scanf("%d",&n)){
      printf("Case%d:\n",T++);
      if(n==0) 
          printf("*\n");
      else {
          s=3*n;
          for(i=0;i<n;i++){
              s--;
             for (j=0;j<s; j++)
                printf("");
             for (k=0; k<2*i+2;k++) {
                if(k%2)
                    printf("*");
                else 
                    printf(" ");
              }
             printf("\n");
           }
          t=-1;
          s=3*n+1;
          for (i=0; i<n+1; i++) {
              t++;
             for (k=0; k<t; k++)
                printf("");
             for (j=i; j<s; j++){ 
                if(j==i)
                    printf("*");
                else 
                    printf(" *");
              }
             printf("\n");
           }
           t=n;
          s=2*n+1;
          for (i=0; i<n; i++) {
              t--;
              s++;
             for (k=0; k<t; k++) {
                printf("");
              }
             for (j=0; j<s; j++) {
                if(j==0)
                    printf("*");
                else 
                    printf(" *");
              }
             printf("\n");
           }
          s=2*n;
          for(i=n;i>0;i--){
              s++;
             for (j=0;j<s-1; j++)
                printf("");
             for (k=2*i; k>0; k--) {
                if(k%2)
                    printf("*");
                else 
                    printf(" ");
              }
             printf("\n");
           }
       }
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值