回分類題庫
d186: CP Lab Exercise: Sub-DNA
出處:

Difficulity : N/A
Accepted : 79 Times | Submit :276 Times | Clicks : 1465
Accepted : 60 Users | Submit : 62 Users | Accepted rate : 97%
Time Limit :10000 ms | Memory Limit : 64000 KBytes
題目加入時間 : 2010-11-24 16:00

Content :

Doctor Li has a gene comparison project.
You are asked to write a program to determine whether the second input string is a sub-DNA of the first.

A sub-DNA is truncated from the original DNA.
To simplify, we only truncate from the beginning of a DNA.

For example:
Origin: ABCDE
sub-DNA are: ABCDE, BCDE, CDE, DE, E
BCD is not a sub-DNA of ABCDE

Notice:
You have to implement a function called isEqual. The prototype is as follow:

int isEqual( const char *str1, const char * str2);

    Returns 1 if str1 is equal to str2 ,
    Else, returns 0.

You have to use pointer arithmetic to extract a sub-DNA from a DNA.
(Pointer arithmetic: +, -, +=, -=)

 

Input :

The first line is a positive number N: the number of tested DNA set.
The following lines are the DNA sets. Each line contains two input strings.
The first string is the DNA and the second is a possible sub-DNA. (What you are going to check!)

Output :

For each DNA set, print out whether second input is a sub-DNA of first input or not.

STR2 is STR1's sub-DNA.
STR2 is STR1's asetd’s sub-DNA

where STR1 and STR2 are the two input strings, see the sample input and output.

Sample Input :

2
acedf cedf
asetd sc

Sample Output :

cedf is acedf's sub-DNA.
sc is not asetd's sub-DNA.

Hint :


  

Author :


  Solve it!   Status Forum (0)

C++
C
JAVA
57081. johnny (4 ms , 228KB)
58696. amy1 (6 ms , 426KB)
46753. sy2es956304 (6 ms , 382KB)
30227. ayakamuxin (2 ms , 222KB)
27156. cp99703039 (2 ms , 220KB)
30718. nothinglo (4 ms , 220KB)
27441. cp98304001 (4 ms , 220KB)
27304. cp99703050 (4 ms , 222KB)
53016. nwgs524513cja (110 ms , 186KB)

執行時間會受很多因素影響因此僅供參考,主機等級請看這裡