新手!不知道什么错了,要求 1489 各个位数的数字输出
#include "stdio.h"char*fun(int n)
{
int g,s,b,a;
g=n/10;
s=n/10%10%10;
b=n/100%10;
a=n/1000;
}
main()
{
int num1=1489;
printf("%s\n",fun(num1));
}
[ 本帖最后由 ckh520520 于 2014-7-13 21:09 编辑 ]
程序代码:/*
* File: main.cpp
* Author: Administrator
*
* Created on 2014年7月13日, 下午9:47
*/
#include <cstdlib>
#include <cstdio>
using namespace std;
static bool isFinished = false;//flag loop
/*
*The cycle to obtain each digit
*/
void print(const int& nValue)
{
if (isFinished)
return ;
//
int lValue = nValue%10;
int rValue = nValue/10;
//
if (0 == rValue)
isFinished = true;
printf("%d ", lValue);
print(rValue);
}
int main(int argc, char** argv)
{
int a = 1489;
print(a);
return 0;
}
