Description
You are given a car odometer which displays the miles traveled as an integer. The odometer has a defect, however: it proceeds from the digit 3 to the digit 5, always skipping over the digit 4. This defect shows up in all positions (the one's, the ten's, the hundred's, etc.). For example, if the odometer displays 15339 and the car travels one mile, odometer reading changes to 15350 (instead of 15340).
Input
Each line of input contains a positive integer in the range 1..999999999 which represents an odometer reading. (Leading zeros will not appear in the input.) The end of input is indicated by a line containing a single 0. You may assume that no odometer reading will contain the digit 4.
Output
Each line of input will produce exactly one line of output, which will contain: the odometer reading from the input, a colon, one blank space, and the actual number of miles traveled by the car. 
Sample Input
aaarticlea/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAARABIDASIAAhEBAxEB/8QAGAABAAMBAAAAAAAAAAAAAAAAAAMFBwT/xAAlEAACAQQCAQMFAAAAAAAAAAABAgMABAURBiESIjFBMjZxdbP/xAAYAQACAwAAAAAAAAAAAAAAAAAAAwEEBf/EABsRAQEAAgMBAAAAAAAAAAAAAAEAAgMEEyFh/9oADAMBAAIRAxEAPwDQeRW+SyVnctBIkiiScOk87qm0ciP0aZWA8dkEDZA2fcGPCWPI+PXkUt3GIcQjkyQxTGdtMrAhUVQO5CraVd/UB1pa7cnHmbaW5hjxEktoZJJGulnjChWYsT4lvLoHvr3B1vommvuQYaSe/jGSxrW9yXEiCWIiTe9eWohvs/LH8n5ocDh9jlnsER+zt+9wDE9G0uKWO4hSaGRJIpFDI6MCrKewQR7ilVfFPs7B/r4P5rStB8ZJW9KUqIlKUoi//9k=" alt="" /> Copy sample input to clipboard 
13
15
2003
2005
239
250
1399
1500
999999
0
Sample Output
13: 12
15: 13
2003: 1461
2005: 1462
239: 197
250: 198
1399: 1052
1500: 1053
999999: 531440
分析:根据题目,在十进制里面去掉了4,那么也就是变成了9进制。然后因为跳过了4,那么大于4的值显然就应该减1
#include <iostream>
#include <cmath> using namespace std; int main(int argc, char const *argv[])
{
int number, numT;
while (cin >> number && number != ) {
numT = number;
int k = ;
int result = ;
while (number) {
int t = number % ;
t = t >= ? t - : t;
result += t * pow(, k++);
number /= ;
}
cout << numT << ": " << result << endl;
}
return ;
}

最新文章

  1. Storm UI 说明
  2. c#如何读取相机手机的拍摄时间
  3. Hibernate学习笔记(四)关系映射之一对一关联映射
  4. 【noip2012】疫情控制
  5. Android_listView_exc
  6. spring中context:property-placeholder/元素 转载
  7. Java学习日记-11 集合(1)
  8. c# 与 c++ 编译
  9. 每天学点Linux:七
  10. Android的AsyncTask类的解读
  11. QDataStream对QVector的序列化
  12. [LeetCode] Convert BST to Greater Tree 将二叉搜索树BST转为较大树
  13. array数组(n,1)和(n,)互相转换
  14. 20151224今天发现到的两篇关于CSS架构、可复用可维护CSS和CSS学习提升能有改变思想观念意识的文章 分别是CSS架构目标和说说CSS学习中的瓶颈
  15. js中slice方法(转)
  16. 快速排序 Java实现的快速排序
  17. logstash报错401 需要在logstash启动的配置文件中增加es的用户名和密码
  18. vue input,textarea失去焦点调用函数方法
  19. [na]ip包格式
  20. 转:Java中String与byte[]的转换

热门文章

  1. Android四大组件之Service(续)
  2. 【HLSDK系列】怎么增加一种新实体
  3. Django之form表单提交并验证
  4. java学习2-webserver测试工具soapUI使用
  5. Ckeditor与Ckfinder(java)整合实现富媒体内容编辑(支持文件上传)
  6. 【BZOJ3028】食物(生成函数)
  7. LINUX内核分析第四周——扒开系统调用的三层皮
  8. http_load - 集成测试工具之
  9. android ndk 编译的时候指令集的选取
  10. 前端解放生产力之–动画(Adobe Effects + bodymovin + lottie)