Runtime Error
/in/foo.cc: In member function 'void sb::add(sb, sb)': /in/foo.cc:19:8: warning: statement has no effect [-Wunused-value] a[i]%10; ~~~~^~~
代码
#include<bits/stdc++.h>
using namespace std;
struct sb{
int a[1500],len=1;
void init(int x)
{
a[1]=x;len=1;
}
void add(sb x,sb y)
{
len=max(x.len,y.len);
for(int i=1;i<=len;i++)
{
a[i]=x.a[i]+y.a[i];
}
for(int i=1;i<=len;i++)
{
a[i+1]+=a[i]/10;
a[i]%10;
}
if(a[len+1]>0)
{
len++;
}
}
void print()
{
for(int i=len;i>=1;i--)
{
cout<<a[i];
}
}
}f[5005];
int main()
{
int n;
cin>>n;
f[1].init(1);
f[2].init(2);
for(int i=3;i<=n;i++)
{
f[i].add(f[i-1],f[i-2]);
}
f[n].print();
return 0;
}