这个代码输出好像有点问题
#include<bits/stdc++.h>
using namespace std;
char str[5005];
struct node{
int len,s[5005];
node() {len=0;memset(s,0,sizeof(s));}
};
node operator / (const node &a,int b){
node c; c.len=a.len;
long long x=0;
for(int i=a.len;i>=1;i--){
x=x*10+a.s[i];
c.s[i]=x/b;
x%=b;
}
while(!c.s[c.len]) c.len--;
return c;
}
node read(){
node c;
scanf("%s",str);
int len=strlen(str);
for(int i=1;i<=len;i++)
c.s[i]=str[len-1]-'0';
c.len=len;
return c;
}
void print(const node &a){
for(int i=a.len;i>=1;i--)
printf("%d",a.s[i]);
}
int main(){
node a,c;a=read();
int p;
scanf("%d",&p);
c=a/p;
print(c);
return 0;
}
幸好我没试,否则:
稻花香里说丰年,听取WA声一片。 E=mc2