24h購物| | PChome| 登入
2012-03-19 14:12:40| 人氣1,151| 回應0 | 上一篇 | 下一篇

[UVA] 621 - Secret Research

推薦 0 收藏 0 轉貼0 訂閱站台

Secret Research 

At a certain laboratory results of secret research are thoroughly encrypted. A result of a single experiment is stored as an information of its completion:


`positive result', `negative result', `experiment failed' or `experiment not completed'


The encrypted result constitutes a string of digits S, which may take one of the following forms:


$bullet$
positive result 		 S = 1 or S = 4 or S = 78 
$bullet$
negative result 		 S = S35 
$bullet$
experiment failed 		 S = 9S4 
$bullet$
experiment not completed 		 S = 190S

(A sample result S35 means that if we add digits 35 from the right hand side to a digit sequence then we shall get the digit sequence corresponding to a failed experiment)


You are to write a program which decrypts given sequences of digits.

Input 

A integer n stating the number of encrypted results and then consecutive n lines, each containing a sequence of digits given as ASCII strings.

Output 

For each analysed sequence of digits the following lines should be sent to output (in separate lines):


		 + 		  for a positive result
		 - 		  for a negative result
		 * 		  for a failed experiment
		 ? 		  for a not completed experiment

In case the analysed string does not determine the experiment result, a first match from the above list should be outputted.

Sample Input 

4
78
7835
19078
944

Sample Output 

+
-
?
*

很水的, 我還以為是什麼語法判斷, 結果根本不是


#include <stdio.h>
#include <string.h>
int main() {
int n, l;
char s[10000];
scanf("%d", &n);
while(n--) {
scanf("%s", s);
l = strlen(s);
if(s[l-1] == '5')
puts("-");
else if(s[0] == '9' && s[l-1] == '4')
puts("*");
else if(s[0] == '1' && l >= 3)
puts("?");
else
puts("+");
}
return 0;
}
 


台長: Morris
人氣(1,151) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[UVA][LIS&LDS] 10131 - Is Bigger Smarter?
此分類上一篇:[UVA][DP] 674 - Coin Change

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文