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:
    • positive result S = 1 or S = 4 or S = 78
    • negative result S = S35
    • experiment failed S = 9S4
    • 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
+
-
?
*

问题链接:UVA621 Secret Research
问题简述:(略)
问题分析
    给定一个字符串,若为“1”,“4”,“78”则输出‘+’;若最后两个字符为“35”则输出‘-’;若首字符为‘9’并且尾字符为‘4’则输出‘*‘;否则输出’?‘。
    简单的字符串判定题,用C语言的字符串库函数(string.h)就可以实现。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA621 Secret Research */#include <bits/stdc++.h>using namespace std;const int N = 512;
char s[N];int main()
{int n, len;scanf("%d", &n);while(n--) {scanf("%s", s);len = strlen(s);if(strcmp(s, "1") == 0 || strcmp(s, "4") == 0 || strcmp(s, "78") == 0)putchar('+');else if(s[len - 2] == '3' && s[len - 1] == '5')putchar('-');else if(s[0] == '9' && s[len - 1] == '4')putchar('*');elseputchar('?');putchar('\n');}return 0;
}

UVA621 Secret Research【水题】相关推荐

  1. UVA 621 Secret Research

    额.. 不理解这题为什么会是数学题 0.0 可能是输入中有很长的字符串需要处理,然后获得字符串的位数是一个需要技巧的过程? 不过我直接STL过的 ...真心感觉STL很方便 但是也不能依赖STL额.. ...

  2. 水题/poj 1852 Ants

    1 /* 2 PROBLEM:poj1852 3 AUTHER:Nicole 4 MEMO:水题 5 */ 6 #include<cstdio> 7 using namespace std ...

  3. HDU2673-shǎ崽(水题)

    如果不能够直接秒杀的题,就不算水题.又应证了那句话,有时候,如果在水题上卡住,那么此题对于你来说,也就不算是水题了额~~ 刚睡醒,迷迷糊糊. 题目的意思很简单,求一个最大的,再求一个最小的.几乎是什么 ...

  4. 图论刷水题记录(二)(最短路-----SPFA算法)

    继第一篇的后续,又来刷水题了,写的是SPFA算法,这个算法的复杂度比较玄学,感觉能不用就不用了,但是他的好处就是可以判断负圈. 3月26日: 1.POJ 1847 Tram 题意:在一个交通网络上有N ...

  5. 图论刷水题记录(一)(最短路-----dijkstra算法)

    最近实在不知道干些什么,感觉自己除了水题什么都不会做,算了去刷一刷图论的水题吧本来想合起来一起发,想了想太长的话以后看起来也不方便,题目所以今天晚上就先发了dij部分,由上到下由易变难. 1.POJ ...

  6. hdu 2041:超级楼梯(水题,递归)

    超级楼梯Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submissio ...

  7. HDU2568 前进【水题】

    前进 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submiss ...

  8. CF Round #426 (Div. 2) The Useless Toy 思维 水题

    题目链接: http://codeforces.com/contest/834/problem/A 题目描述: 输入起始状态和结束状态和数列长度, 判断旋转方向是顺时针逆时针还是不合理 解题思路: 长 ...

  9. NUC1312 Sum【水题+数学题】

    Sum 时间限制: 1000ms 内存限制: 65536KB 通过次数: 1总提交次数: 1 问题描述 认为自然数是从1-N.将每个数和+或-联系起来,然后计算这个表达式的值我们得到一个和S.这个问题 ...

最新文章

  1. 项目管理的四个基本阶段及流程(干货)
  2. 201671010117 2016-2017-2 《Java程序设计》Java第二周学习心得
  3. 人脸识别的过程和算法
  4. 解决Xcode升级,导致以前安装的插件失效的办法
  5. 基于FPGA的电机控制设计(PWM)
  6. Adobe illustrator 魔棒工具批量操作 - 连载 7
  7. Matlab程序怎样打包
  8. Scatter-gather DMA 与 block DMA
  9. ARP协议及欺骗原理
  10. Linux查看硬盘型号
  11. B2C,B2B,c2c是什么?
  12. GIS开发:Contour(轮廓线)
  13. 手机信令数据怎么获得_论文推荐 | 基于手机信令数据的大规模通勤模式研究(2020-12-01)...
  14. aspose设置两个word拼接后连续页码
  15. 满二叉树和完全二叉树的区别
  16. .NET中Hangfire快速入门和使用-迷恋自留地
  17. 整理一批 国内外优秀设计团队 设计相关网站
  18. Amazon技术图书近期热点
  19. 近距离观看WhatsUp Gold Virtualization
  20. 计算机设备管理器没有网络适配器,设备管理器没有网络适配器,小编教你Win7设备管理器中没有网络适配器如何恢复...

热门文章

  1. cocos2d-x CCArray用法 遍历和删除元素
  2. 【java学习之路】(java框架)001.Maven配置及使用
  3. jquery mysql jsp_jsp+jquery+mysql实现的一个简单的学生管理系统
  4. Hive 中类SQL语言中的 oder by,gruop by的区别
  5. transaction already active
  6. doris同步作业配置参数修改和注意事项
  7. MySQL 之 约束 (主键、唯一、非空、自增、外键)
  8. 肇庆市二技学校计算机电算化,肇庆市有那些技术学校
  9. 发票打印JAVA是什么_如何使用蓝牙热敏打印机打印发票收据
  10. Git教程——查看修改日志 (log diff)