More actions
imported>joojis No edit summary |
(Repair batch-0005 pages from live compare) |
||
| (3 intermediate revisions by one other user not shown) | |||
| Line 6: | Line 6: | ||
void swap(int *a, int *b){ | void swap(int *a, int *b){ | ||
int temp; | int temp; | ||
temp=*a; | temp=*a; | ||
*a=*b; | *a=*b; | ||
*b=temp; | *b=temp; | ||
} | } | ||
//분석해보세요 | |||
a^=b^=a^=b; | void swap(int *a, int *b){ | ||
if((*a)!=(*b)){ | |||
*a^=*b^=*a^=*b; | |||
} | } | ||
} | |||
int main() | |||
{ | |||
int x=5, y=10; | |||
printf("%d %d\n", x, y); | |||
swap(&x, &y); | |||
printf("%d %d\n", x, y); | |||
return 0; | |||
} | } | ||
== 문자열 출력 == | == 문자열 출력 == | ||
| Line 22: | Line 38: | ||
} | } | ||
} | } | ||
int main() | |||
{ | |||
printstring("abcd"); | |||
return 0; | |||
} | } | ||
Latest revision as of 00:45, 27 March 2026
출석
*권우성
수업 내용
스왑
void swap(int *a, int *b){
int temp;
temp=*a;
*a=*b;
*b=temp;
}
//분석해보세요
void swap(int *a, int *b){
if((*a)!=(*b)){
*a^=*b^=*a^=*b;
}
}
int main()
{
int x=5, y=10;
printf("%d %d\n", x, y);
swap(&x, &y);
printf("%d %d\n", x, y);
return 0;
}
문자열 출력
void printstring(char *ptr){
while(*ptr){
putc(*ptr, stdout);
ptr++;
}
}
int main()
{
printstring("abcd");
return 0;
}