**题目描述
The fight goes on, whether to store numbers starting with their most significant digit or their least significant digit. Sometimes this is also called the “Endian War”. The battleground dates far back into the early days of computer science. Joe Stoy, in his (by the way excellent) book “Denotational Semantics”, tells following story:

“The decision which way round the digits run is, of course, mathematically trivial. Indeed, one early British computer had numbers running from right to left (because the spot on an oscilloscope tube runs from left to right, but in serial logic the least significant digits are dealt with first). Turing used to mystify audiences at public lectures when, quite by accident, he would slip into this mode even for decimal arithmetic, and write things like 73+42=16. The next version of the machine was made more conventional simply by crossing the x-deflection wires: this, however, worried the engineers, whose waveforms were all backwards. That problem was in turn solved by providing a little window so that the engineers (who tended to be behind the computer anyway) could view the oscilloscope screen from the back.

You will play the role of the audience and judge on the truth value of Turing’s equations.

输入
The input contains several test cases. Each specifies on a single line a Turing equation. A Turing equation has the form “a+b=c”, where a, b, c are numbers made up of the digits 0,…,9. Each number will consist of at most 7 digits. This includes possible leading or trailing zeros. The equation “0+0=0” will finish the input and has to be processed, too. The equations will not contain any spaces.

输出
For each test case generate a line containing the word “TRUE” or the word “FALSE”, if the equation is true or false, respectively, in Turing’s interpretation, i.e. the numbers being read backwards.**
这道题就是,输入等式后 把等式中的各个整数颠倒后再进行相加,判断是否成立,且以“0+0=0”作为结束。
例如输入61+51=13输出TRUE,因为将各个数字颠倒后为16+15=31,该式子成立
用find标记这是第几个数,从后往前判断,若find 为1,则为第一个数,若find 为2,则为第二个数,若find为3,则为第三个数,在最后判断一下,若第二个数加第三个数等于第一个数 则输出true。从后往前遍历时,记得跳过前导0

#include<stdio.h>
#include<string.h>char str[100];int main()
{int l,i,sum,find,d1,d2,d3;while(scanf("%s",str)!=EOF){l = strlen(str);if(strcmp(str,"0+0=0")==0)break;while(str[l-1] == '0')l--;if(str[l-1] == '=')l++;find = 0;sum = 0;for( i = l-1; i >= 0;i--){sum = 0;while(str[i]>= '0'&&str[i]<='9'){sum = sum*10 + str[i]-'0';i--;}if( sum >= 0)find ++;if(find == 1)d1 = sum;if(find == 2)d2 = sum;if(find == 3)d3 = sum;}if( d2 + d3 == d1)printf("TRUE\n");elseprintf("FALSE\n");}return 0;
}

转载于:https://www.cnblogs.com/hellocheng/p/7350169.html

河南省第七届省赛 问题 F: Turing equation 水题相关推荐

  1. 蓝桥杯嵌入式STM32G431——第七届省赛真题模拟液位检测告警系统

    第七届省赛真题模拟液位检测告警系统 第七届省赛真题 主函数部分的代码功能实现(不包含各模块初始化代码) 第七届省赛真题 主函数部分的代码功能实现(不包含各模块初始化代码) #include " ...

  2. 河南省第十届省赛 Plumbing the depth of lake (模拟)

    title: Plumbing the depth of lake 河南省第十届省赛 题目描述: There is a mysterious lake in the north of Tibet. A ...

  3. 蓝桥杯单片机第七届省赛-模拟风扇控制系统

    九层妖塔 起于垒土 ● 改编自国信长天蓝桥杯官方蓝皮书例程,按照自己的习惯进行了补充和修改 蓝桥杯单片机第七届省赛-模拟风扇控制系统 Notes1:按键按下后在某些情况下给一定的缓冲时间 Notes2 ...

  4. 蓝桥杯嵌入式——第七届省赛-模拟液位检测告警系统

    第七届省赛-模拟液位检测告警系统 目录 第七届省赛-模拟液位检测告警系统 一.赛题分析 二.代码 一.赛题分析 这一届和上一届也就是第六届一样,没有涉及到定时器得PWM输出和输入捕获.主要得赛题难度是 ...

  5. 河南省第十届省赛 Intelligent Parking Building

    title: Intelligent Parking Building 河南省第十届省赛 tags: [模拟,省赛] 题目描述: There is a new revolution in the pa ...

  6. 第六届省赛(软件类)真题----Java大学A组答案及解析

    第六届省赛(软件类)真题----Java大学A组答案及解析 熊怪吃核桃 星系炸弹 九数分三组 循环节长度 打印菱形 加法变乘法 牌型种数 移动距离 垒骰子 灾后重建 一.熊怪吃核桃 森林里有一只熊怪, ...

  7. 第六届省赛(软件类)真题----Java大学B组答案及解析

    第六届省赛(软件类)真题----Java大学B组答案及解析 三角形面积 立方变自身 三羊献瑞 循环节长度 九数组分数 加法变乘法 牌型种数 饮料换购 垒骰子 生命之树 一.三角形面积 如[图1]所示. ...

  8. 第六届省赛(软件类)真题----Java大学C组答案及解析

    第六届省赛(软件类)真题----Java大学C组答案及解析 隔行变色 立方尾 无穷分数 循环节长度 格子中输出 奇妙的数字 加法变乘法 移动距离 打印大X 垒骰子 一.隔行变色 Excel表的格子很多 ...

  9. 蓝桥杯嵌入式第七届省赛——“模拟液位检测告警系统”旧板标准库

    一.赛题分析 模拟液位检测告警系统,涉及到KEY.ADC.EEPROM.LED.USART.LCD等模块.本届赛题相对简单,各个模块均可在往期文章中找到配置方法和编写说明.如: 蓝桥杯嵌入式--第六届 ...

最新文章

  1. mysql存放图片的数据表_mysql数据库可以存图片吗?
  2. atomic与nonatomic,assign,copy与retain的定义和区别
  3. 买台式电脑还是笔记本好?
  4. NLP中各框架对变长序列的处理全解
  5. 关于Thinkphp3.2版本的分页问题
  6. HtmlParser提取网页中的纯文本信息
  7. Bash教程之模式扩展
  8. 子集和问题 算法_LeetCode刷题实战90:子集 II
  9. Junit 4.x 单元测试,参数化测试,套件测试 实例
  10. 州的先生 python界面 代码完整版(注释)
  11. 达内android 代码,深圳达内Android网页源码查看器.pdf
  12. 以太坊2.0客户端Lighthouse发布v1.3.0版本,为高优先级建议立即更新
  13. 滑动窗口:字符串的变位词(排列)leetcode567,leetcode438
  14. 那天有个小孩跟我说LINQ(三)
  15. 串标是什么意思?用同一台电脑制作或上传投标书,会被认定为串标吗?
  16. 用python自动制作ppt第二讲——插入文字的两种方法和追加文字
  17. 浅谈常见浏览器缓存方法(前端缓存)
  18. 2014网络红人排行榜
  19. python转换整数_在Python中将数字转换为整数列表
  20. uniapp nvue运用map组件实现地图标注以及检索周边地址

热门文章

  1. Java并发编程之线程同步
  2. 云上建站快速入门:博客、论坛、CMS、电子商务网站统统搞定
  3. u3d无锯齿遮罩shader-可用于ugui
  4. Putty、Xshell连接Linux
  5. String与NSString关系
  6. PowerDesigner逆向生成
  7. jdk1.8.0_45源码解读——Map接口和AbstractMap抽象类的实现
  8. 陶哲轩实分析习题 12.1.3
  9. UVA1103分区涂色+vc使用注意事项
  10. 通过angular.js实现MVC的基本步骤