C++
C++)포인터 이용해서 배열숫자 바꾸기
알 수 없는 사용자
2010. 5. 14. 09:39
#include <iostream>
using namespace std;
void swap(int *a, int x, int y);
void main()
{
int a[] = {1,2,3,4,5,6,7,8,9};
int x,y;
cout << "바꿀 숫자를 입력하세요:";
cin >> x >> y;
swap(a,x,y);
for(int i=0; i<9; i++)
cout << a[i] << endl;
}
void swap(int *a, int x, int y)
{
a[x-1] = y;
}