代碼:ios
1 #include <iostream> 2 using namespace std; 3 int main() 4 { 5 int array[2]; 6 for (int i = 0; i < 2; i++) { 7 cin >> array[i]; 8 } 9 int temp = array[0]; 10 array[0] = array[1]; 11 array[1] = temp; 12 for (int i = 0; i < 2; i++) { 13 cout << array[i] << " " ; 14 } 15 return 0; 16 }
結果:spa