输出求助!
  • 板块P1480 A/B Problem
  • 楼主lzh009
  • 当前回复8
  • 已保存回复8
  • 发布时间2023/5/21 12:09
  • 上次更新2023/10/23 15:08:51
查看原帖
输出求助!
952814
lzh009楼主2023/5/21 12:09

这个代码输出好像有点问题

#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 E=mc^2

2023/5/21 12:09
加载中...