0

i was writing this program for a competition, and I got the error message "no matching function call for 'Ninety'" I am relatively new to programming, so if someone could help me out that would be great. Thanks!

#include <iostream>
#include <cstring>

using namespace std;

void Ninety(int N, char old[N][N], char finished[N][N]){

    char newer[N][N];
    for(int i = 0; i<N; i++){
            for(int j=0; j<N; j++){
                newer[i][j] =  old[(N-1)-j][i];
            }
        }
    if(finished[N][N] == newer[N][N]){
        cout<<"Y "<<endl;
    }

}

int main() {
    int N;
    cin>>N;
    char old[N][N], finished[N][N];
    for(int i = 0; i<N; i++){
        for(int j = 0; j<N; j++){
            cin>>old[i][j];
        }
    }
    for(int i = 0; i<N; i++){
        for(int j = 0; j<N; j++){
            cin>>finished[i][j];
        }
    }
    Ninety(N, old, finished);

}
  • 1
    Variable length arrays (VLAs) like `char newer[N][N]` are *not* part of the C++ language, although some compilers support them as an extension. You need to specify which compiler you are using in order for your code to be properly analysed and debugged. – Adrian Mole Aug 15 '20 at 21:36
  • Managing 2D arrays as function input in C++ requires some knowledge about [pointers](http://www.cplusplus.com/doc/tutorial/pointers/). You may find some explanation [here](http://www.cplusplus.com/doc/tutorial/arrays/) on how you can access array's elements. You may use also [std::vector](http://www.cplusplus.com/reference/vector/vector/) in alternative to old-fashioned arrays. – Eddymage Aug 15 '20 at 21:37
  • 1
    Using a parameter to size variable length array parameters is pretty much a C-only thing. I'm not aware of any C++ compilers that include an extension allowing that. Remove all of the C++isms and you will have a C program that compiles and probably overflows the stack. Replace all of the Cism's with [something like this](https://stackoverflow.com/a/2076668/4581301) and you might be a bit better off. Recommendation: Learn the language and then compete. No point showing up at the track meet to run the 100m dash while still learning to walk. – user4581301 Aug 15 '20 at 22:20
  • 2
    Side note: Whatever route you take, watch out for `if(finished[N][N] == newer[N][N])`, The matrices are only valid for indexes in the range (0,N]. – user4581301 Aug 15 '20 at 22:44

0 Answers0