×

# whats wrong with this code for permutation problem?

 0 #include #include int main(){ int n, i,m=0; scanf("%d",&n); while(n!=0){ int a[n],b[n]; for(i=0;i

 3 There are few errors in your code:: (1)The output that you are printing doesn't matches the output format as mentioned in problem statement. You are not printing a newline after "ambiguous" or "not ambiguous" {printf("ambiguous")};THE NEW LINE IS MISSING.This is the most common mistake committed by the beginners. Please note that the code chef judge compile your code and generate the output in a plain text file and matches your output file with the expected (their official) output file,thus even an xtra white-space can results in wrong answer.So always make sure,your code generates the output precisely in the same format as mentioned in problem statement. (2).There is a small mistake in this section of code  { m++; if(m==n) { printf("ambiguous"); m=0; }; } else{ printf("not ambiguous"); break; m=0; }; };  You are not breaking printing ambiguous.So it will print multiple times and ofcourse the missing of newline character as i mentioned is blunder here. I have corrected your code and it will get accepted now.This is the correct code::  #include #include int main() { int n, i,m=0,flag; scanf("%d",&n); while(n!=0) { int a[n],b[n]; for(i=0;i
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×538
×146

question asked: 18 May '12, 22:50

question was seen: 999 times

last updated: 13 Feb, 23:18