WOJ 1003 - Birth of Noah
来源:互联网 发布:网易公开课 网络不给力 编辑:程序博客网 时间:2024/04/27 18:09
这题要求处理输入的两个名字a和b
第一行输出Yes/No表明a是否是b的祖先;输出"No enough information"如果题意没有给出
第二行输出相同的格式,表明a是否比b活的久。
因此这题要求通读description,找出family tree以及每个人的寿命。
然后就可以很容易地处理了。
以下是本题涉及到的人物:
Adam 930 1
Seth 912 2
Enosh 905 3
Kenan 910 4
Mahalalel 895 5
Jared 962 6
Enoch 365 7
Methuselah 969 8
Lamech 777 9
Noah 0 10
Shem Ham Japheth 0 11
注意本题未告诉数据有多少组,需要使用这样的代码格式
第一行输出Yes/No表明a是否是b的祖先;输出"No enough information"如果题意没有给出
第二行输出相同的格式,表明a是否比b活的久。
因此这题要求通读description,找出family tree以及每个人的寿命。
然后就可以很容易地处理了。
以下是本题涉及到的人物:
Adam 930 1
Seth 912 2
Enosh 905 3
Kenan 910 4
Mahalalel 895 5
Jared 962 6
Enoch 365 7
Methuselah 969 8
Lamech 777 9
Noah 0 10
Shem Ham Japheth 0 11
注意本题未告诉数据有多少组,需要使用这样的代码格式
while(scanf("%s%s", a, b) != EOF){
//do sth.
}
//do sth.
}
附完整代码:
#include<stdio.h>#include<stdlib.h>#include<string.h> int main() { char *a[13]={"Adam","Seth","Enosh","Kenan","Mahalalel", "Jared","Enoch","Methuselah","Lamech","Noah", "Shem","Ham","Japheth"}; int b[13]={1,2,3,4,5, 6,7,8,9,10, 11,11,11}; int c[9]={930,912,905,910,895, 962,365,969,777}; char str1[100],str2[100]; while(scanf("%s%s",str1,str2)!=EOF) { int i=0,j=0; int x,y; x = 0;y = 0; for(i=0;i<13;i++) { if(!strcmp(a[i],str1)) x=i; } for(j=0;j<13;j++) { if(!strcmp(a[j],str2)) y=j; } if(b[x]<b[y]) printf("Yes\n"); else printf("No\n"); if(x>8||y>8) printf("No enough information\n"); else { if(c[x]>c[y]) printf("Yes\n"); else printf("No\n"); } } return 0;}
0 0
- WOJ 1003 - Birth of Noah
- woj1003 - Birth of Noah
- WOJ1003-Birth of Noah
- WOJ-Problem 1003- birth of Noal
- WOJ:Problem 1004 - Noah's Ark
- WOJ-Problem 1004 - Noah's Ark
- Birth of a Seaver
- WOJ-1003
- Growing Pains402 Birth of a Seaver
- woj 1006 Language of Animals
- woj 1022 Competition of Programming
- WOJ-6 Language of Animals
- WOJ
- woj
- XML Files - The Birth of Web Services 笔记 (一)
- XML Files - The Birth of Web Services 笔记 (二)
- 内存的诞生(The birth of Memory)
- faux louis vuitton Since the birth of Louis Vuitton
- C++ 文件模式
- HDOJ 2602 Bone Collector【01背包】
- 全局对象 静态数据成员
- Codeforces Round #291 (Div. 2) -- A. Chewbaсca and Number
- 浅谈SQLite——查询处理及优化
- WOJ 1003 - Birth of Noah
- Android手机分辨率基础知识(DPI,DIP计算)
- Sql server best practise for Index
- Codeforces Round #291 (Div. 2) -- B. Han Solo and Lazer Gun (计算几何~暴力)
- 散
- codeforces 294E Shaass the Great (树形dp,好题)
- iOS 上架流程(三)
- HDU--4704 Sum【费马小定理,快速幂】
- Web Service概述