#include<stdio.h>
void swap_a(int a,int b){
int tmp;
tmp = a;
a = b;
b = tmp;
}
void swap_b(int*a,int*b){
int tmp;
tmp =*a;
*a = *b;
*b = tmp;
}
void swap_c(int*a,int*b){
int *tmp;
tmp = a;
a = b;
b = tmp;
}
void swap_print(int a,int b){
printf("a = %d,b = %d\n",a
,b
); }
int main(){
int a,b;
a = 100; b = 200;
swap_print(a,b);
swap_a(a,b);
swap_print(a,b);
printf("参照渡しで関数に引数を受け渡した場合ー1,"); swap_b(&a,&b);
swap_print(a,b);
printf("参照渡しで関数に引数を受け渡した場合ー2,"); swap_c(&a,&b);
swap_print(a,b);
return(0);
}
I2luY2x1ZGU8c3RkaW8uaD4KCnZvaWQgc3dhcF9hKGludCBhLGludCBiKXsKICAgIGludCB0bXA7CiAgICB0bXAgPSBhOwogICAgYSA9IGI7CiAgICBiID0gdG1wOwp9Cgp2b2lkIHN3YXBfYihpbnQqYSxpbnQqYil7CiAgICBpbnQgdG1wOwogICAgdG1wID0qYTsKICAgICphID0gKmI7CiAgICAqYiA9IHRtcDsKfQoKdm9pZCBzd2FwX2MoaW50KmEsaW50KmIpewogICAgaW50ICp0bXA7CiAgICB0bXAgPSBhOwogICAgYSA9IGI7CiAgICBiID0gdG1wOwp9Cgp2b2lkIHN3YXBfcHJpbnQoaW50IGEsaW50IGIpewogICAgcHJpbnRmKCJhID0gJWQsYiA9ICVkXG4iLGEsYik7Cn0KCmludCBtYWluKCl7CiAgICBpbnQgYSxiOwoKICAgIGEgPSAxMDA7IGIgPSAyMDA7CiAgICBzd2FwX3ByaW50KGEsYik7CgogICAgcHJpbnRmKCLlgKTmuKHjgZfjgafplqLmlbDjgavlvJXmlbDjgpLlj5fjgZHmuKHjgZfjgZ/loLTlkIgsIik7CiAgICBzd2FwX2EoYSxiKTsKICAgIHN3YXBfcHJpbnQoYSxiKTsKCiAgICBwcmludGYoIuWPgueFp+a4oeOBl+OBp+mWouaVsOOBq+W8leaVsOOCkuWPl+OBkea4oeOBl+OBn+WgtOWQiOODvO+8kSwiKTsKICAgIHN3YXBfYigmYSwmYik7CiAgICBzd2FwX3ByaW50KGEsYik7CgogICAgcHJpbnRmKCLlj4LnhafmuKHjgZfjgafplqLmlbDjgavlvJXmlbDjgpLlj5fjgZHmuKHjgZfjgZ/loLTlkIjjg7zvvJIsIik7CiAgICBzd2FwX2MoJmEsJmIpOwogICAgc3dhcF9wcmludChhLGIpOwoKICAgIHJldHVybigwKTsKfQo=