why this code showing me unusual behaviour

Revision en3, by FARMAAN_KHANN, 2023-02-12 08:12:15

#include <iostream> using namespace std; bool solve1(long long small,long long big){ int s=0; while(small>0){ s+=small%10; small/=10; } int k = 0; while(big>0){ k+=big%10; big/=10; } // cout<<s<<" "<<k<<'\n'; if(s==k){ return true; }else return false; } void solve(){ long long n; cin>>n; for(long long i=1;i<n;i++){ cout<<i<<'\n'; if(solve1(i,n-i)){ // cout<<'\n'; cout<<i<<" "<<n-i<<'\n'; return; } } } int main() { int t; cin>>t; while(t--){ solve(); } }

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English FARMAAN_KHANN 2023-02-12 08:12:45 18
en3 English FARMAAN_KHANN 2023-02-12 08:12:15 11
en2 English FARMAAN_KHANN 2023-02-12 08:11:38 2 Tiny change: '#include <' -> '``#include <'
en1 English FARMAAN_KHANN 2023-02-12 08:11:14 625 Initial revision (published)