이 질문이 도움이 될 경우 투표하십시오. :)C99에서 'sum'함수의 암시 적 선언이 유효하지 않습니다.
나는 이것에 대한 해결책을 찾고 있었지만 도움이 될만한 것을 찾지 못했습니다. 오류가 발생합니다 : - C99에서 'sum'함수의 암시 적 선언이 유효하지 않습니다. - 'average'함수의 암시 적 선언이 C99에서 유효하지 않습니다. - 'average'의 충돌 유형 누구든지 전에 경험 했습니까? Xcode에서 컴파일하려고합니다.
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool
{
int wholeNumbers[5] = {2,3,5,7,9};
int theSum = sum (wholeNumbers, 5);
printf ("The sum is: %i ", theSum);
float fractionalNumbers[3] = {16.9, 7.86, 3.4};
float theAverage = average (fractionalNumbers, 3);
printf ("and the average is: %f \n", theAverage);
}
return 0;
}
int sum (int values[], int count)
{
int i;
int total = 0;
for (i = 0; i < count; i++) {
// add each value in the array to the total.
total = total + values[i];
}
return total;
}
float average (float values[], int count)
{
int i;
float total = 0.0;
for (i = 0; i < count; i++) {
// add each value in the array to the total.
total = total + values[i];
}
// calculate the average.
float average = (total/count);
return average;
}
나를 위해 매력처럼 작동이 답변을 확인하십시오! https://stackoverflow.com/a/46221365/3063226 – Heitor