(错误思路)char输进,判断a[0]是否为‘-’,然后转回ull。
查看原帖
(错误思路)char输进,判断a[0]是否为‘-’,然后转回ull。
273217
Mithrandir楼主2020/5/31 08:22
#include <bits/stdc++.h>
#define ull unsigned long long
using namespace std;
ull o=0;char a[65];int b[65]={-1},len;
bool hp(char x[])
{
int k=0;
if(x[0]>'9'||x[0]<'0') return 0;
for(int i=0;i<len;i++)
	b[len-i]+=x[i];
for(int i=1;i<=len;i++)
o+=(b[i]-'0')*pow(10,i-1);
return 1;
}
int main()
{
cin>>a;
len=strlen(a);
o=0;
if(hp(a))
cout<<(o-1)*2+1;
else cout<<0;
return 0;
}

30分求大佬帮看看哪儿错了。

2020/5/31 08:22
加载中...