zoukankan      html  css  js  c++  java
  • 几道水题(18岁的生日,空心三角形)

    18岁的生日:

     1 #include<stdio.h>
     2 int m[13]={31,28,31,30,31,30,31,31,30,31,30,31};
     3 int nian(int x){
     4     if(x%400==0||(x%4==0&&x%100!=0))return 1;
     5     else return 0;
     6 }
     7 int find(int x,int y,int z){
     8     if(nian(x))m[1]=29;
     9     else m[1]=28;
    10     int tot=0;
    11     for(int i=0;i<y-1;i++)tot+=m[i];
    12     return tot+z;
    13 }
    14 int main(){
    15     int x,y,z,tot,T;
    16     scanf("%d",&T);
    17     while(T--){tot=0;scanf("%d-%d-%d",&x,&y,&z);
    18         if(y==2&&z==29)puts("-1");
    19         else{
    20             for(int i=x+1;i<x+18;++i){
    21                 if(nian(i))tot+=366;
    22                 else tot+=365;
    23             }
    24             if(nian(x))tot+=366-find(x,y,z);
    25             else tot+=365-find(x,y,z);
    26             printf("%d
    ",tot+find(x+18,y,z));
    27         }
    28     }
    29     return 0;
    30 }

    空心三角形:

    #include<stdio.h>
    #include<string.h>
    int main(){
        char c,m[100][100];int n,x,y,flot=0;
        while(scanf("%c %d",&c,&n),c!='@'){memset(m,0,sizeof(m));if(flot)puts("");flot++;
            getchar();
            for(y=0;y<n;++y)for(x=0;x<2*n;++x)m[y][x]=' ';
            for(y=0;y<n;++y){
                for(x=0;x<2*n;++x){
                    m[y][n-1-y]=c;
                    m[y][n-1+y]=c;
                    if(y==n-1)m[y][x]=c;
                    m[y][n+y]='';
                }
                printf("%s
    ",m[y]);
            }
        }
        return 0;
    }
  • 相关阅读:
    安全扫描英汉对照意思
    文件包含漏洞
    文件上传漏洞
    XSS攻击
    常用命令
    适用于 Python 的 AWS 开发工具包 (Boto3)
    SQS 设置长轮询
    Amazon SNS 消息属性
    SQS Queues and SNS Notifications – Now Best Friends
    Policy Evaluation Logic 策略评估逻辑
  • 原文地址:https://www.cnblogs.com/handsomecui/p/4674170.html
Copyright © 2011-2022 走看看