Task Description
整數交換
撰寫一函式將兩個整數交換。
Hint
swap.h
打上 function header 以及相關的設定。void swap(int *x, int *y);
swap.c
撰寫程式碼後對應上傳。#include "swap.h"void swap(int *x, int *y) { / add your code /}
main.c
這個檔案無法更改也無須上傳。123456789101112131415 #include <stdio.h>#include "swap.h" int main(){ int a; int b; scanf("%d %d", &a, &b); swap(&a, &b); printf("%d %d\n", a, b); return 0; }
Input Format
測試資料為兩整數a,b。
Output Format
請撰寫一函示使程式印出兩整數交換的結果。
Sample Input
1 3 5
Sample Output
1 5 3