제발 도와주세요. 크기가 두 개의 정수 배열 인 을 합산해야하고 함수의 인수로 각 배열의 첫 번째 요소를 전달해야하는 함수가 있습니다. 이 닫힙니 까?정수 배열을 C에서 함수 매개 변수로 전달
12 void sumVect(int * v[], int * w[] ,int n)
13 //adds the second vector to the first vector; the vectors v and w have exactly n components
14 {
15 int i;
16 for(i=0;i<n;i++)
17 {
18 *v[i]+=*w[i];
19 }
20
21 }
나는 전체 코드를 당신이 유형 int []
을 전달하는
#include <stdio.h>
void sumVect(int * v[], int * w[] ,int n)
//adds the second vector to the first vector; the vectors v and w have exactly n components
{
int i;
for(i=0;i<n;i++)
{
*v[i]+=*w[i];
}
}
int main()
{
int i,j;
int n = 4; //the size of a vector
int k = 5; //the number of vectors
int v[k][n]; //the vector of vectors
printf("How many vectors? k=");
scanf("%d",&k);
printf("How many components for each vector? n=");
scanf("%d",&n);
for(i=1;i<=k;i++) //read the content of each vector from the screen
{
printf("\nv%d |\n_____|\n",i);
for(j=0;j<n;j++)
{
printf("v%d[%d]=",i,j);
scanf("%d", &v[i][j]);
}
}
for(j=1;j<k;j++)
{
sumVect(&v[j], &v[j+1], n);
for(i=0;i<n;i++)
{
printf("%d",v[j][i]);
}
}
return 0;
}
덕분에 많이, 내가 당신에게 한 맥주 :)) – NiCU
downvote 원인을 빚 완벽한 설명을?(참고, 오류 고정) – phoxis
죄송합니다, 저는 기본 영어 사용자가 아니므로 downvote가 무슨 뜻입니까? – NiCU