473,396 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem regarding a solution in uri online judge

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 2517
weaknessforcats
9,208 Expert Mod 8TB
Please post your code. Virus concerns prevent me from following a link.
Jun 16 '16 #2
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
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
  1.     #include <stdio.h>
  2.  
  3.     int main()
  4.     {
  5.         int N, i, j, array[100][100]={{0}};
  6.  
  7.         while(scanf("%d", &N) != EOF){
  8.             for(i=0; i<N; i++){
  9.                 for(j=0; j<N; j++){
  10.                     if((i>=N/3 && i<(N-(N/3))) && (j>=N/3 && j<(N-(N/3)))){
  11.                         array[i][j] = 1;
  12.                     }
  13.                     else if(i==j){
  14.                         array[i][j] = 2;
  15.                     }
  16.                     else if(j == (N-i-1)){
  17.                         array[i][j] = 3;
  18.                     }
  19.                 }
  20.             }
  21.  
  22.             array[N/2][N/2] = 4;
  23.  
  24.             for(i=0; i<N; i++){
  25.                 for(j=0; j<N; j++){
  26.                     printf("%d", array[i][j]);
  27.                 }
  28.                 printf("\n");
  29.             }
  30.             printf("\n");
  31.         }
  32.  
  33.         return 0;
  34.     }
  35.  
  36.  
Jun 16 '16 #4
weaknessforcats
9,208 Expert Mod 8TB
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

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Esmeralda Weatherwax | last post by:
For 10 days now, a new online judge (a system for the verification of the correctness of submitted programs, which solve problems selected from a repository) has been available to the public. ...
0
by: Esmeralda Weatherwax | last post by:
For 10 days now, a new online judge (a system for the verification of the correctness of submitted programs, which solve problems selected from a repository) has been available to the public. ...
1
by: Shreyas Kulkarni | last post by:
hi there, recently i have got a problem regarding calculation of sum of digits in a floating point or precision number. the weird behaviour of compiler/language is preventing me from calculating...
1
by: Atul Sharma | last post by:
hi friends i m getting problem regarding wht assemblies are? why they r used? & how they r created?
0
by: RAM | last post by:
Hello, I have installed SQL Server 2005 with Books Online. I have a problem with Books Online. I can use index but I cannot use "Search" command - I receive a message box with text "Package...
2
by: ThunderMusic | last post by:
Hi, I have a class library with some classes... One of those classes fire events from a different thread. When I try to display the information contained in the event args of this event in my UI,...
6
by: ashokfig | last post by:
Hi All, I'm facing problem regarding Accessing secure web page. I tried to connect page through progamming & want access data from web page. I passed Login credentials & also certificate which...
0
by: mahesh123 | last post by:
Hi, I am new to use the crystal reports8.0. I am facing the problem regarding the database connection through the ADO Connection. Suppose my database name is "sample.pra"(due to some security...
2
by: Mukesh9023 | last post by:
<?php $file_string = file_get_contents('http://delhi.tradus.com/puma-axis-ii-ind-silver-lime-green-sports-shoes/p/FTWN4FH29KD29I2T?tag=19622&tsrc=TagListing'); preg_match('#<span...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.