zoukankan      html  css  js  c++  java
  • zoj3839-Poker Face

    #include<cstdio>
    int n;
    void P(int i,int j,int n,int f){
    if(i==n){
    for(int k=1;k<=n;k++)printf("*");
    if(!f) puts("");
    }
    else if(i==1){
    for(int k=1;k<=n;k++)printf("*");
    if(!f){puts("");
    P(i+1,1,n,f);}
    else printf("*");
    }
    else if(i==n/8+1||i==n/4+n/8+1){
    printf("*");
    for(int k=2;k<n/8+1;k++)printf(" ");
    for(int k=n/8+1;k<n/4+n/8+1;k++)printf("*");
    for(int k=n/4+n/8+1;k<n/8+n/2+1;k++)printf(" ");
    for(int k=n/8+n/2+1;k<=3*n/4+n/8;k++)printf("*");
    for(int k=3*n/4+n/8+1;k<n;k++)printf(" ");
    if(!f){puts("*");
    // (j>n/8+1&&j<n/4+n/8||j>n/8+n/2+1&&j<n/8+3*n/4)
    P(i+1,1,n,f);}
    else printf("*");
    }
    else if(i>n/8+1&&i<n/4+n/8+1){
    printf("*");
    for(int k=2;k<n/8+1;k++)printf(" ");printf("*");
    for(int k=n/8+2;k<n/4+n/8;k++)printf(" ");printf("*");
    for(int k=n/4+n/8+1;k<n/8+n/2+1;k++)printf(" ");printf("*");
    for(int k=n/8+n/2+2;k<3*n/4+n/8;k++)printf(" ");printf("*");
    for(int k=3*n/4+n/8+1;k<n;k++)printf(" ");
    if(!f){
    puts("*");
    // (j>n/8+1&&j<n/4+n/8||j>n/8+n/2+1&&j<n/8+3*n/4)
    P(i+1,1,n,f);}
    else printf("*");
    }
    // else if(i>=n/8+1&&i<=n/8+n/4+1&&(j==n/8+1||j==n/8+n/4||j==n/8+n/2+1||j==n/8+3*n/4))printf("*"),P(i,j+1,n);
    else if(i==n/2+1){
    printf("*");
    for(int k=2;k<n/4+1;k++)printf(" ");
    for(int k=n/4+1;k<=n-n/4;k++)printf("*");
    for(int k=n-n/4+1;k<n;k++)printf(" ");
    if(!f){puts("*");
    P(i+1,1,n,f);}
    else printf("*");
    }
    else if(i>n/2+1&&i<n){
    if(n==8){
    if(i==5)printf("* **** *");
    else printf("* * * *");
    if(!f){puts("");
    P(i+1,1,n,f);}
    }
    //if(j>=n/4+1&&j<=n-n/4)printf("*"),P(i,j+1,n);
    else {
    printf("*");
    for(int k=2;k<n/4+1;k++)printf(" ");
    P(n-i+1,1,n/2,1);
    for(int k=n-n/4+1;k<n;k++)printf(" ");
    if(!f){puts("*");
    P(i+1,1,n,0); }
    else printf("*");
    }
    }
    else {
    printf("*");
    for(int k=2;k<=n-1;k++)printf(" ");
    if(!f){puts("*");
    P(i+1,1,n,f);}
    else printf("*");
    }
    return ;
    }
    int main(){
    while(scanf("%d",&n)&&n>=8){
    P(1,1,n,0);
    puts("");
    }
    }

  • 相关阅读:
    开发JQuery插件标准结构
    JavaScript中的正则表达式
    IntelliJ IDEA 之Web的Facets/Artifacts(八)
    IntelliJ IDEA 快捷键(七)
    IntelliJ IDEA 集成各种插件(六)
    [转]VS2010几款超赞的扩展辅助工具总结
    创建和使用动态链接库(转)vs2008 vs2010
    springboot 自定义Repository
    springboot redis 缓存对象
    springboot 集成spring-session redis 实现分布式session
  • 原文地址:https://www.cnblogs.com/newadi/p/4135817.html
Copyright © 2011-2022 走看看