twogoat @ 2016-12-14 16:53:11
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int a,s=1,b,j[10001],h,k=1,bt=0;
cin>>a;
if(a<0)
{
a=a*-1;
cout<<"-";
}
b=a;
while(1)
{
h=b%10;
if(b==0) break;
b=b/10;
j[s]=h;
s++;
}
for(int i=1;i<=s-2;i++)
{
k=k*10;
}
for(int i=1;i<=s-1;i++)
{
j[i]=j[i]*k;
k=k/10;
}
for(int i=1;i<=s-1;i++)
{
bt=bt+j[i];
}
cout<<bt;
}
by BFSBFSBFSBFS @ 2016-12-14 22:43:54
还可以.取位再乘回来...
by Focus_on @ 2016-12-16 07:52:26
看看我的,用字符数组
#include<string>
#include<cstring>
#include<cstdio>
#include<memory.h>
#define For(a) for(int i=a;i<n;i++);
using namespace std;
int main(){
char ss[20];
bool flag=0;
memset(ss,'\0',sizeof(ss));
gets(ss);
int n=strlen(ss)-1;
if(ss[0]=='-'){
printf("-");
flag=1;
}
int t=n;
while(ss[t]=='0') t--;
if(flag==1)
for(int i=t;i>=1;i--) printf("%c",ss[i]);
else
for(int i=t;i>=0;i--) printf("%c",ss[i]);
return 0;
}
by 双城 @ 2016-12-17 19:00:30
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
char s[1000];
int sum=0;
gets(s);
int len=strlen(s);
for(int i=len-1;i>=0;i--)
{
if(s[i]=='0'&&s[i-1]=='0')
sum++;
if(s[i]=='0'&&s[i-1]!='0')
{
sum++;break;
}
}
if(s[0]=='-')
{
cout<<"-";
for(int i=len-1-sum;i>=1;i--)
cout<<s[i];
}
else{
for(int i=len-1-sum;i>=0;i--)
cout<<s[i];
}
return 0;
}
好奇怪居然AC了,可是如果输56065的话会少一个数欸
by wudi2016 @ 2016-12-24 20:57:58
#include<bits/stdc++.h>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstdlib>
#include<string>
#include<iomanip>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
int n;
scanf("%d",&n);
bool yes;
if(n<0){
yes=1;
n=-n;
}
int ans=0;
for(int i=n;i>0;i/=10){
ans=ans*10+i%10;
}
if(yes){
ans=-ans;
}
printf("%d\n",ans);
return 0;
}