truyền tham số dùng biến tạm
#include <stdio.h>
#include <conio.h>
#include <iostream>
using namespace std;
void swap1(int a, int b)
{
int temp=a;
a=b;
b=temp;
}
int main()
{
int x=10, y=20;
swap1(x,y);
cout<<" x= "<<x
<<" y= "<<y
<<endl;
getch();
return 0;
}
Không có nhận xét nào:
Đăng nhận xét