会计题库网站怎么做,网页编辑用什么软件,江苏省示范校建设专题网站,在百度怎么建立自己的网站#xfeff;#xfeff;#xfeff;题目解决代码及点评/*输入数字 n#xff0c;按顺序输出从 1 最大的 n 位 10 进制数。比如输入 3#xff0c;则输出 1、2、3一直到最大的 3 位数即 999。
*/#include iostream
using namespace std;//在不考虑大数的情况下#… 题目解决代码及点评/*输入数字 n按顺序输出从 1 最大的 n 位 10 进制数。比如输入 3则输出 1、2、3一直到最大的 3 位数即 999。
*/#include iostream
using namespace std;//在不考虑大数的情况下只要简单找出最大数然后循环打印即可
void Print1(int n)
{if (n 0){return;}int nMax 1;// 获得最大数for (int i 0; i n; i){nMax * 10;if (nMax INT_MAX || nMax INT_MIN){return;}}// 循环打印即可for (int i 1; i nMax; i){coutiendl;}
}void PrintNumber(char *pszBuf, int nLen)
{int i 0;while(pszBuf[i] 0){i;}while (i nLen){coutpszBuf[i];i;}cout ;
}
void printRecurive(char *pszBuf, int nLen, int nIndex)
{if (nLen nIndex){PrintNumber(pszBuf, nLen);}else{for (int i 0; i 9; i){pszBuf[nIndex] i 0;printRecurive(pszBuf, nLen, nIndex 1);}}}
// 如果要考虑大数那么应该用字符串来表示数
void Print2(int n)
{if (n 0){return;}char *pszBuf new char[n];// 递归的打印printRecurive(pszBuf, n, 0);}
int main()
{int n;cinn;Print2(n);system(pause);return 0;
}
代码下载及其运行代码下载地址http://download.csdn.net/detail/yincheng01/6704519解压密码c.itcast.cn下载代码并解压后用VC2013打开interview.sln并设置对应的启动项目后点击运行即可具体步骤如下1设置启动项目右键点击解决方案在弹出菜单中选择“设置启动项目”2在下拉框中选择相应项目项目名和博客编号一致3点击“本地Windows调试器”运行程序运行结果 转载于:https://www.cnblogs.com/niulanshan/p/6175132.html