N
NJpixie
Hello,
Here is my code of a perimeter of a triangle such as:
2
1 7
3 6 8
4 2 5 3
#include <iostream>
using namespace std;
int perimeterSum (int[][]A, int Size);
int main()
}
int perimeterSum(int[][]A, int size){
int sum = 0;
// the left-hand side (the first column)
for (int i = 0; i < size; i++)
sum += A[0];
// the bottom row, except the first element
for (int i = 1; i < size; i++)
sum += A[A - 1];
// the diagonal except the first and last elements
for (int i = 1; i < size - 1; i++)
sum += A;
return sum;
}
}
i am only on chapter 3 so the code needs to be very basic using:
int perimeterSum (int[][] A, int Size) {
int sum = 0;
I tried this code but i got 4 errors in visual c++.
The errors are:
C:\Documents and Settings\perimeter.cpp(6) : error C2087: '<Unknown>' :
missing subscript
C:\Documents and Settings\perimeter.cpp(6) : error C2146: syntax error
: missing ')' before identifier 'A'
C:\Documents and Settings\perimeter.cpp(6) : error C2146: syntax error
: missing ';' before identifier 'A'
C:\Documents and Settings\perimeter.cpp(6) : fatal error C1004:
unexpected end of file found
Error executing cl.exe.
What am I doing wrong?
Here is my code of a perimeter of a triangle such as:
2
1 7
3 6 8
4 2 5 3
#include <iostream>
using namespace std;
int perimeterSum (int[][]A, int Size);
int main()
}
int perimeterSum(int[][]A, int size){
int sum = 0;
// the left-hand side (the first column)
for (int i = 0; i < size; i++)
sum += A[0];
// the bottom row, except the first element
for (int i = 1; i < size; i++)
sum += A[A - 1];
// the diagonal except the first and last elements
for (int i = 1; i < size - 1; i++)
sum += A;
return sum;
}
}
i am only on chapter 3 so the code needs to be very basic using:
int perimeterSum (int[][] A, int Size) {
int sum = 0;
I tried this code but i got 4 errors in visual c++.
The errors are:
C:\Documents and Settings\perimeter.cpp(6) : error C2087: '<Unknown>' :
missing subscript
C:\Documents and Settings\perimeter.cpp(6) : error C2146: syntax error
: missing ')' before identifier 'A'
C:\Documents and Settings\perimeter.cpp(6) : error C2146: syntax error
: missing ';' before identifier 'A'
C:\Documents and Settings\perimeter.cpp(6) : fatal error C1004:
unexpected end of file found
Error executing cl.exe.
What am I doing wrong?