+ 2
swap two variable a , b
#include<iostream> using namespace std; int main() { int a, b; cout<<"Enter n. to A and B"<<"\n"; cin>>a>>b; cout<<"\n"<<"Before Value"<<"\n"<<"A="<<a<<"\n"<<"B="<<b; a+=b; b=a-b; a-=b; cout<<"\n"<<"After Value"<<"\n"<<"A="<<a<<"\n"<<"B="<<b; return 0; }
6 Respuestas
+ 1
jst edit one line, where you write a=b .. instead of a=b there is b=a... try it... almost all things are correct..
+ 1
a+=b;
b=a - b;
a-=b;
+ 1
okay..
+ 1
yury d, very nice formula... thanks a lots
+ 1
np
0
jst edit one line, where you write a=b .. instead of a=b there is b=a... try it... almost all things are correct..