435,254 Members | 2,365 Online
Need help? Post your question and get tips & solutions from a community of 435,254 IT Pros & Developers. It's quick & easy.

# Problem regarding a solution in uri online judge

 P: 3 Hello, I am new at this forum and this is my first post. Today, I was solving problem no. 1827 in URI online judge. Problem link I wrote my code and tested it and it was giving correct answer and I am pretty sure that my logic is correct but in the online judge it is showing 90% wrong thus not accepted. I could not figure out the problem in my code. Please if anyone can take a look at my code. My code link Thanks to everyone. Jun 16 '16 #1
4 Replies

 Expert Mod 5K+ P: 9,197 Please post your code. Virus concerns prevent me from following a link. Jun 16 '16 #2

 P: 3 Thanks for the assistance. The link that is given for my solution is from popular online code sharing site ideone.com (http://ideone.com/BJwzFY) which surely can never be a virus and I had to post the whole code to make everyone understand which could be bigger. So you could safely visit the link. Even then if you have the confusion, tell me. I will reply the code here. Thank you. Jun 16 '16 #3

 P: 3 Sorry for the inconvenience. I was out of my pc for a while so could not post the code. Here is my code: Expand|Select|Wrap|Line Numbers     #include        int main()     {         int N, i, j, array[100][100]={{0}};           while(scanf("%d", &N) != EOF){             for(i=0; i=N/3 && i<(N-(N/3))) && (j>=N/3 && j<(N-(N/3)))){                         array[i][j] = 1;                     }                     else if(i==j){                         array[i][j] = 2;                     }                     else if(j == (N-i-1)){                         array[i][j] = 3;                     }                 }             }               array[N/2][N/2] = 4;               for(i=0; i

 Expert Mod 5K+ P: 9,197 From reading Problem 1827 you are to accept a number which is the size of a square matrix. In the URI example outout, they use 5. You should then allocate a 5x5 array. Snce this array is created at run time you use malloc() to allocate the memory. Your solution doesn't do this. It creates a 100x100 array hard-coded. My advice is to create a 5x5 array as shown in the Problem 1827 output example. Make your program produce the example output. Post again after you have accomplished this. Jun 16 '16 #5