第1个回答 2008-10-11
#include<iostream>
using namespace std;
int main()
{
int integer,intcopy;
int len=0,count=0,i=0;
char intstr[100];
cin>>integer;
intcopy=integer;
while(intcopy)
{
intcopy/=10;
len++;
}
count=len;
len--;
while(integer!=0)
{
intstr[len--]=char((integer%10)+48);
integer/=10;
}
intstr[count]='\0';
while(intstr[i]!='\0')
{
cout<<intstr[i++];
}
cout<<endl;
system("pause");
return 0;
}本回答被提问者采纳
第2个回答 2008-10-11
凑合著用吧!
#include <stdio.h>
#include <stdlib.h>
int main(){
char g[100];
int x;
scanf("%d",&x);
printf("%s",itoa(x,g,10));
return 0;
}
第3个回答 2008-10-11
# include <stdio.h>
void tr(int x)
{int i,a=1;
char *p;
for(i=1;i<10;i++)
{a=a*10;
if(a>=x)
break;
}
p[i]='\0';
while(i>=0)
{i--;
p[i]=x%10+48;
x=x/10;
}
puts(p);
}
main()
{ int a;
printf("please input a ");
scanf("%d",&a);
tr(a);
getch();
}
凑合着用吧
第4个回答 2008-10-11
有库函数,非得要自己实现吗?
库函数是atoi系列