点击(此处)折叠或打开
// sa.cpp.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include<iostream> #include <cstdio> #include <iostream> using namespace std; inline bool IsOne(int &side, unsigned int &number) { return ((1 << side) & number) > 0; } void Funs(unsigned int n) { if (n <= 0) { printf("error\n"); return ; } ++n; char chrResult[33]; int iSide, iCount; iSide = 31; iCount = 0; while (iSide >= 0 && !IsOne(iSide, n)) --iSide; --iSide; while (iSide >= 0) { if(IsOne(iSide, n)) { chrResult[iCount++] = '7'; } else { chrResult[iCount++] = '4'; } --iSide; } chrResult[iCount] = '\0'; printf("%s\n", chrResult); return; } int main() { unsigned int n; while (scanf("%u", &n) != EOF) { Funs(n); } return 0; } <script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script> 阅读(71) | 评论(0) | 转发(0) | 0上一篇:socket中的短连接与长连接,心跳包示例详解
下一篇:Shell脚本常识(基本知识)
相关热门文章 test123编写安全代码——小心有符号数...使用openssl api进行加密解密...一段自己打印自己的c程序...彻底搞定C语言指针详解-完整版... 给主人留下些什么吧!~~ 评论热议