hdu2629 水题

/*

hdu2629 题意 输入一个18位的身份证号码 前六位是地区 再八位是出生年月日 后四位特殊标号

前六位地区 在题目中有八个地区 ,输出 

He/She is from “地区”,and his/her birthday is on 月,日,年 based on the table.
if语句就好 问题就是输入 我用了scanf的控制输入语句 但是WA料想是输入字符串 而我用的是整形数组,菜不成声

*/

#include <stdio.h> //AC代码 别人的 
#include <string.h>//hdu  2629
int main()
{ 
    int n;char a[19];scanf("%d",&n);
    while(n--) 
    {
        int year,mon,day;char s[10];
        scanf("%s",a);
        printf("He/She is from "); 
        if     (a[0]=='3' && a[1]=='3'){ printf("Zhejiang");}//字符比较
        else if(a[0]=='1' && a[1]=='1'){ printf("Beijing");}
        else if(a[0]=='7' && a[1]=='1'){ printf("Taiwan");}
        else if(a[0]=='8' && a[1]=='1'){ printf("Hong Kong");}
        else if(a[0]=='8' && a[1]=='2'){ printf("Macao");}
        else if(a[0]=='5' && a[1]=='4'){ printf("Tibet");}
        else if(a[0]=='2' && a[1]=='1'){ printf("Liaoning");}
        else if(a[0]=='3' && a[1]=='1'){ printf("Shanghai");}
        
        printf(",and his/her birthday is on ");
        printf("%c%c,%c%c,%c%c%c%c",a[10],a[11],a[12],a[13],a[6],a[7],a[8],a[9]);
        printf(" based on the table.\n");
    }
    return 0;
}

#include <stdio.h>//我写的 CE 
#include <string.h>//hdu  2629
int main()
{ 
    int n;int s[10];scanf("%d",&n);
    while(n--) 
    {
        int s[10],year,mon,day;char s[20];
        scanf("%1d%1d%1d%1d%1d%1d%4d%2d%2d%*d",&s[1],&s[2],&s[3],&s[4],&a[5],&a[6],&year,&mon,&day);
        printf("He/She is from ");
        if(s[1] == 3 && s[2] == 3)      printf("Zhejiang");  
        else if(s[1] == 1 && s[2] == 1) printf("Beijing");  
        else if(s[1] == 7 && s[2] == 1) printf("Taiwan");  
        else if(s[1] == 8 && s[2] == 1) printf("Hong Kong");  
        else if(s[1] == 8 && s[2] == 2) printf("Macao");  
        else if(s[1] == 2 && s[2] == 1) printf("Liaoning");
        else if(s[1] == 5 && s[2] == 4) printf("Tibet");  
        else if(s[1] == 3 && s[2] == 1) printf("Shanghai");  
        
        printf(",and his/her birthday is on ");
        printf("%d,%d,%d based on the table.\n",mon,day,year);
    }
    return 0;
}

#include <stdio.h>  
#include <string.h>  
  
int main()  
{  
    int n;  
    int s[20],i,len;  
    char str[20];  
    scanf("%d%*c",&n);  
    while(n--)  
    {  
        gets(str);  
        len = strlen(str);  
        for(i = 0;i<len;i++)  
        {  
            s[i+1] = str[i]-48;  //将字符重新构建一个数组 
        }  
        printf("He/She is from ");  
        if(s[1] == 3 && s[2] == 3)  
        printf("Zhejiang");  
        else if(s[1] == 1 && s[2] == 1)  
        printf("Beijing");  
        else if(s[1] == 7 && s[2] == 1)  
        printf("Taiwan");  
        else if(s[1] == 8 && s[2] == 1)  
        printf("Hong Kong");  
        else if(s[1] == 8 && s[2] == 2)  
        printf("Macao");  
        else if(s[1] == 2 && s[2] == 1)  
        printf("Liaoning");  
        else if(s[1] == 5 && s[2] == 4)  
        printf("Tibet");  
        else if(s[1] == 3 && s[2] == 1)  
        printf("Shanghai");  
        printf(",and his/her birthday is on %d%d,%d%d,%d%d%d%d based on the table.\n",s[11],s[12],s[13],s[14],s[7],s[8],s[9],s[10]);  
    }  
}  
 
 

转载于:https://www.cnblogs.com/163467wyj/p/8343611.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值