ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1313. Some Words about Sport

Runtime error (access violation) for test #2
Posted by mainuddin_talukdar 30 Sep 2019 20:15
I don't know why this happens to me. Can you please post the test#2 so that I can debug it.
My Code is :
#include <bits/stdc++.h>

using namespace std;

#define frj(a,b)    for(j=a;j<=b;j++)
#define fri(a,b)    for(i=a;i<=b;i++)
#define re return

int main()
{
    int n,i,j, matrix[101][101];

    cin >> n;
    fri(0, n-1)
    {
        frj(0, n-1)
        {
            cin >> matrix[i][j];
        }
    }

    cout << matrix[0][0] << " ";
    i =1, j=0;
    int iNext = 1, jNext = 0;

    while (iNext != n-1 || jNext != n-1)
    {
        i=iNext, j=jNext;
        while (i >= jNext && j<=iNext)
        {
            cout << matrix[i--][j++] << " ";
        }
        if(iNext == n-1)
        {
            jNext++;
        }
        else
        {
            iNext++;
            jNext=0;
        }
    }
    cout << matrix[n-1][n-1] << " ";


    re 0;
}

Edited by author 30.09.2019 20:18