배열을 "정렬"하려고했습니다. 하지만 원래의 배열을 "for 루프"로 표시하는 대신 정상적인 방법을 뛰어 넘어 "org_array"라는 함수에 원래 배열을 전달하기로 결정한 후 "void"로 호출하려고했습니다. 본관()". 그러나 몇 가지 오류가 있습니다. 매개 변수를 전달할 때 오류가 무엇인지 알 수 없습니다. 도와주세요?C++ 오류에서 매개 변수로 배열 전달
코드 :
는#include<iostream>
#include<conio.h>
using namespace std;
extern int s;
void org_array(int arr[30],int y);
void main()
{
int i,n,j,pos,a[30];
cout<<"Enter n: "<<endl;
cin>>n;
cout<<"\nEnter array: "<<endl;
for(i=0;i<n;i++){
cin>>a[i];
}
cout<<"Orginal Array: ";
org_array(a[30],n);
/*for(i=0;i<n;i++){
cout<<a[i]<<" | ";
}*/
for(i=0;i<n-1;i++)
{
int small=a[i];
pos=i;
for(j=i+1;j<n;j++)
{
if(a[j]<small)
{
small=a[j];
pos=j;
}
}
int temp=a[i];
a[i]=a[pos];
a[pos]=temp;
}
cout<<"\tSorted Array: ";
for(i=0;i<n;i++){
cout<<a[i]<<" | ";
}
getch();
}
void org_array(int arr[30],int y){
for(s=0;s<y;s++)
{
cout<<" "<<arr[s];
}
}
어떤 오류를 겪었습니까? – imulsion
C 프로그램을 C++로 작성하는 이유는 무엇입니까? C 언어에 문제가있는 것은 아니지만 다른 언어입니다. 또한, 루프 카운터 (!)를 만드는 데있어 중요한 점은 무엇입니까? – dasblinkenlight