Crash if it is false
It crashes if the n1 isn`t equal with n/s, idk why
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#include <iostream>
using namespace std;
int main()
{int n,n1,n2,a,s;
cin>>n;
cin>>n1;
a=n;
do{a=n;
s=0;
while(a!=0)
{s=a%10+s;
a=a/10;
}
if(n/s==n1)
{cin>>n2;
if(n%s==n2)
cout<<n<<";"<<n1<<";"<<n2<<endl;
else {n=n1;n1=n2;}
}
else {n=n1;
}
}
while(n1!=0);
return 0;
}
|
On line 14 check that s != 0 if(n / s == n1)
What is this program supposed to do?
Topic archived. No new replies allowed.