Life, the Universe, and EverythingProblem code: TEST |
All submissions for this problem are available.
For help on this problem, please check out our tutorial Input and Output (I/O)
Your program is to use the brute-force approach in order to find the Answer to Life, the Universe, and Everything. More precisely... rewrite small numbers from input to output. Stop processing input after reading in the number 42. All numbers at input are integers of one or two digits.
Example
Input: 1 2 88 42 99 Output: 1 2 88
| Author: | admin |
| Date Added: | 23-02-2009 |
| Time Limit: | 3 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC |
Comments
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
|
If you are still having problems, see a sample solution here. |

Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach.
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section.
where should i type the
where should i type the code
is notepad ok?
time limit exceeded error for
time limit exceeded error for following code......plz help me reduce time consumption
#include<stdio.h>
int main(void)
{
unsigned int num;
for(;printf("%d",scanf("%d",&num)!=42););
return(0);
}
Your program never exits.
Your program never exits. Your scanf function will never return 42.
why this doesn't get accepted
why this doesn't get accepted ?
#include <stdio.h>
int main(){
int num=0;
for(;num!=42;printf("%dn", num,scanf("%d", &num)));
return 0;
}
It gives the wrong answer for
It gives the wrong answer for every single input, including the sample input.
Why '\'(backslash) not coming
Why ''(backslash) not coming before n in my code?
Is there any technical problem?
The problem is that you
The problem is that you aren't meant to post code in comments, which you would know if you had read the FAQ. You will also find the solution to your problem there.
Actually I have doubt with
Actually I have doubt with question
After entering all input values the output can listed out (ie) get all values if 42 appears then it print all other values....
eg:
10
20
30
42
o/p 10 20 30
or
if enter one value and it gives output until enter 42
10
10
65
65
42
---->ends
Read the FAQ.
Read the FAQ.
*snip* what is difference b/w
*snip*
what is difference b/w lower code and upper code.....????
lower is correct...
and in upper code case..it prints wrong answer
The upper code starts by
The upper code starts by printing out "How Many values do you want to input". That is not part of the correct solution, so you get wrong answer. Please read the FAQ.
Why do you insist on posting
Why do you insist on posting your code in the comments?
Do you not understand what this site is supposed to be about?
How do we accept input for
How do we accept input for C++??
Will cin work, or we have to input from file?
I just wrote the solution of
I just wrote the solution of this problem in C# and there what was astonishing that i just input, compare and display till 42 is entered.
Time: 0.19 secs
Mem: 11.2M
A lot of solutions in C / C++ does almost the same, but they have a better Time and Memory performance. Is it normal for C# to take more memory and time ?
I am very new to this forum,
I am very new to this forum, I wrote this program as the practice, but it gave me runtime error. Could you let me know, what I need to do?
Thanks
You could start by reading
You could start by reading the FAQ.
please if anyone can tell me
please if anyone can tell me why d codechef compiler is telling "wrong answer" of this solution..........
need assistance...
d program is giving required output on my cmd.........
You aren't meant to output
You aren't meant to output the word 'output'. You also shouldn't assume there are only 50000 numbers in the input, but you might get lucky and get accepted anyway.
i have also verified Through
i have also verified Through FAQ i am getting Run Time (Other) i checked with un used variables There arent any :) And memory also i havent declared more than necessary
Please Help
@aweety:dont know the error
@aweety:dont know the error bt dont use printf("enter the number") line it will give error on codechef compiler
@sweety:dont know the error
@sweety:dont know the error bt dont use printf("enter the number") line it will give error on codechef compiler
Getting Run Time error
Getting Run Time error :(:(
Can some body help please ??
I am able to Execyte perfectly on my Ecllipse
import java.util.Scanner;
public class Main {
public static void main (String args[])
{
int i=1;
int []anArray;
anArray = new int[100];
while (true)
{
Scanner scanner = new Scanner(System.in);
anArray[i] = scanner.nextInt();
if((anArray[i])==42)
{
break;
}
// System.out.print("n In loop"+i+"n");
i++;
}
// System.out.print("n After coming out of loop "+i+"n");
for (int pos=1;pos<i;pos++)
{
System.out.println(anArray[pos]);
// System.out.print("n Printing the value of Pos:"+pos+"n");
}
}
}
Please read the FAQ (in
Please read the FAQ (in particular, 'other common mistakes'; same applies to Scanners).
Hi Stephen i changed the
Hi Stephen
i changed the Scanner and taking input from Buffers Stream ,, It still shows Run Time error
I debugged it and i think i have made sure that its not doint any thng what is mentioned in
FAQ ..
Please Help pasting the modified code
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main (String args[])
{
int i=0;
int []anArray;
String line=null;
anArray = new int[100];
while (true)
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
line=br.readLine();
anArray[i] = Integer.parseInt(line);
System.out.print("n In loop value Stored"+anArray[i]+"n");
} catch (IOException e) {
e.printStackTrace();
}
if((anArray[i])==42)
{
break;
}
System.out.print("n In loop"+i+"n");
i++;
}
// System.out.print("n After coming out of loop "+i+"n");
for (int pos=0;pos<i;pos++)
{
System.out.println(anArray[pos]);
}
}
}
You didn't read the bit I
You didn't read the bit I mentioned. The point is whatever you use, you should only create one such object on the standard input stream, not once every loop.
#include<stdio.h> int
#include<stdio.h>
int main()
{
int t;
while(1)
{
scanf("%d",&t);
if(t==42||t>99)
break;
printf("%d",t);
}
return 0;
}
Its Showing correct Output on my PC
using System; class
using System;
class Life_Universe_and_Everything
{
static void Main(string[] args)
{
int n=1, a;
Console.Write("How many numbers do you want to enter ?");
n = int.Parse(Console.ReadLine());
int[] array1 = new int[n];
for (int i = 0; i < n; i++)
{
a = int.Parse(Console.ReadLine());
if (a < 100)
array1[i] = a;
else
{
Console.WriteLine("Enter Only 1 or 2 Digit numbers");
i--;
}
}
for (int i = 0; i < n; i++)
{
if (array1[i] != 42)
Console.WriteLine(array1[i]);
else
i = n;
}
}
}
public class Main{ private
public class Main
{ private static int readInt() throws Exception
{ int i=0;
int r=0;
//while((i=System.in.read())!='n'&&i!='r');
while((i=System.in.read())!='n'&&i!='r')
{ r*=10;
r+=(i-'0');
}
return r;
}
public static void main(String[]arg)throws Exception
{ for(int i=0;(i=readInt())!=42;
System.out.println(i));
}
}
Why does this give a runtime
Why does this give a runtime error?
It runs correctly on my ubuntu 8.04 machine.
#include<stdio.h>
#include<stdlib.h>
int main() {
int i;
while(1) {
scanf("%d", &i);
if(i != 42)
printf("%dn", i);
else
exit(1);
}
}
Do you know what the exit
Do you know what the exit function does? I suggest you read some C documentation on it, and/or read the FAQ.
//hello what is wrong with my
//hello what is wrong with my code please help, they are giving compile error.
import java.util.Scanner;
public class Bruteforce {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int i;
for(;;){
System.out.print("enter int number : n");
i=input.nextInt();
System.out.printf(" %d ", i );
if(i==42){
break;}
}
}
#include<iostream.h> #include
#include<iostream.h>
#include<conio.h>
void main()
{
int a[25],n;
cout<<"n Enter the no. of elements u want to enter:";
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i];
i=0;
while(a[i]!=42)
{
cout<<a[i];
i++;
}
getch();
}
@Ritika: I fear the solution
@Ritika:
I fear the solution is completely wrong!
You need to read the FAQ!
import
import java.util.Scanner;
public class BrutForce
{
public static void main(String... args)
{
Scanner input = new Scanner(System.in);
int number = 0;
while(true)
{
number = input,nextInt();
if (number == 42) break;
System.out.println(number);
}
}
}
#include<stdio.h> #include<co
#include<stdio.h>
#include<conio.h>
#define pf printf
#define sf scanf
void main()
{
int a,i,n;
clrscr();
pf("nn PLZ enter how many times u want to keep entering the value n");
sf("%d",&a);
for(i=1;i<=a;i++)
{
pf("nenter the value but beware do not enter the value 42 or the program will terminatenn");
sf("%d",&n);
if(n==42)
{
pf("caution !!!! u have entered 42 as valuennnt the program will now terminatennpress any key to continuen");
ghetch();
break;
}
pf("nnthe entered value is ===> %dnn",n);
}// end of for
} // end of main
@Nilesh: Please read FAQ!
@Nilesh:
Please read FAQ!
help me with this IN C if i
help me with this IN C
if i use linkd list,time limit exceeds
if i use array i have to give array sze constant
Don't use either. Print each
Don't use either. Print each number as you read it. (See the FAQ if you don't know how your code is tested.)
public static void
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int i;
for(;;){
i=input.nextInt();
if(i!=42)
System.out.printf(" %d ", i );
else
break;
}
}
is this code ok?
#include<stdio.h>int
#include<stdio.h>
int main()
{
int t;
while(1)
{
scanf("%d",&t);
if(t==42)break;
printf("%dn",t);
}
return 0;
}
#include<stdio.h>void main(){
#include<stdio.h>
void main()
{
int i,j,temp,c[99],a[99],b,d;
clrscr();
printf("Enter the no of inputs");
scanf("%d",&b);
printf("Enter the no one by one");
for(i=0;i<b;i++)
{
//printf("n");
scanf("%d",&a[i]);
}
for(i=0;i<b;i++)
{
if(a[i]!=42)
{
c[i]=a[i];
//printf("%d",a);
}
else
{
d=i;
break;
}
}
for(i=0;i<d;i++)
{
for(j=0;i<d;j++)
{
if(c[j]>c[i])
{
temp=c[j];
c[j]=c[i];
c[i]=temp;
}
}
}
for(i=0;i<d;i++)
printf("%dt",c[i]);
getch();
}
This program is running in my turbo c compiler but i cant submit can u help me please
#include <stdio.h>#include
#include <stdio.h>
#include <string.h>
int main()
{
int num[99];
int i,j,temp,a[99];
i=0;
while(scanf("%d",&num[i]))
{
if(num[i]!=42)
{
a[i]=num[i];
d=i;
i++;
}
else
{
break;
}
}
for(i=0;i<d;i++)
{
for(j=0;j<d;j++)
{
if(a[j]>a[i])
{
temp=a[j];
a[j]=a[i];
a[i]=temp;
}
}
}
return 0;
}
what wrong in this program Please anyone help me
while submitting it giving the error wrong answer
#include<stdio.h> int
#include<stdio.h>
int main()
{
int x;
for(;;)
{
scanf("%d",&x);
if(x>0&&x<100&&x!=42)
printf("%dn",x);
else
break;
}
return 0;
}
why the above code is being rejected?
#include "stdio.h" int
#include "stdio.h"
int main(){
int i;
for(;;){
scanf("%d", &i);
if(i != 42){
printf("%dn", i);
} else {
return 0;
}
}
}
#include<stdio.h> void
#include<stdio.h>
void main()
{
int arr[5],i;
printf("enter five intergersn");
for(i=0;i<5;i++)
{
scanf("%d",&arr[i]);
}
for(i=0;i<5;i++)
{
if(arr[i]==42)
break;
else
printf("%dn",arr[i]);
}
getch():
}
can someone please suggest what's wrong with my ans.
#include<stdio.h> int
#include<stdio.h>
int main()
{
int a;
while(1)
{
scanf("%d",&a);
if(a==42)break;
printf("%dn",a);
}
return 0;
}
Okay, I uploaded my .java
Okay, I uploaded my .java file and it told me that there were compile errors! I know that is not true because I compiled the program and ran it several times before I uploaded the file to your site.
I'm using JGrasp to write and compile my Java programs...is that the problem? Do I need to use some other method in order to have a successful upload??
I presume you've read the
I presume you've read the FAQ?
Yes, I've read through the
Yes, I've read through the FAQ but I'm a beginner programmer and the details of the FAQ are vague to me. I can't seem to figure out how your computer compiles the programs. I think I should just drop out of this until I've had a few years of programming experience. Although I was able to successfully get my program to function properly for a user, I am not able to figure out your compiling system...
Vague? It seems pretty
Vague? It seems pretty specific. For example, under the 'Why do I get a compile error' section, it tells you your java class must be called Main. Yours isn't. It also tells you under the first section that you shouldn't be prompting the user for input in a dialog box, and in the second section how to test your code properly.
This is my java code. /* *
This is my java code.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package codechef;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
*
* @author admin
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int input = Integer.parseInt(br.readLine());
while (input != 42) {
System.out.println(input);
input = Integer.parseInt(br.readLine());
}
}
}
class Life{public static void
class Life{
public static void main(String ar[])
{
//command line argument for input
for(int i=0;i<ar.length;i++)
{
if(Integer.parseInt(ar[i])==42)
break;
System.out.println(ar[i]);
}
}
}
admin i posted this following
admin i posted this following program as the solution to this problem.. it is working fine on my compiler but it is showing a run time error here.. can you please tell where the error is?
#include<stdio.h>
void main()
{
int num;
while(1)
{
scanf("%d",&num);
if(num==42)
break;
else
printf("n%d",num);
}
}
admin i submitted this code
admin i submitted this code of mine as a solution to this problem but it is showing some run time error n it is working fine on my compiler... kindly check where the problem actually exists..
#include<stdio.h>
void main()
{
int num;
while(1)
{
scanf("%d",&num);
if(num==42)
break;
else
printf("n%d",num);
}
}
Please read the FAQ.
Please read the FAQ.
did it in first try...felt
did it in first try...felt great... awesome this night is of some worth today: :) time is 1:59 a.m.
i did it in first try.. felt
i did it in first try.. felt great.. :)
My program running fine on my
My program running fine on my compiler whats wrong here
#include<iostream>
using namespace std;
int main()
{
int i=0;
for(;(cin>>i)&&i!=42;cout<<i);
}
i done with this
i done with this problem.....
my question is how this program related with the life ,universe..blah blah
import
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
*
* @author ASP.NET
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int x = Integer.parseInt(br.readLine());
if(x!=42)
System.out.print(x);
}
}
I am getting wrong answer in submission why???
Your program gives the wrong
Your program gives the wrong answer for the sample input. All it prints is 1.
#include<stdio.h> int
#include<stdio.h>
int main()
{
int a;
while(1)
{
printf("%d",a);
scanf("%d",&a);
if(a=42)
break;
}
}
i m beginner help me out
#include<stdio.h> #include<st
#include<stdio.h>
#include<stdlib.h>
int main()
{
int a,n,i;
printf("enter numbers that u are interested ")
scanf("%d",&n)
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
if(a[i]==42)
exit(0);
else
printf("%d",a[i]);
}
}
#include<stdio.h>main(){ int
#include<stdio.h>
main()
{
int a,b;
b=1;
while(b=1)
{
printf("please enter the no.");
scanf("%d",&a);
if (a!=42)
{printf("tt%d",a);
}
else{
b=0;
break;
}
}
return 0;
}
#include<iostream.h> #include
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b[100],p=0;
while(1)
{
cin>>a;
if(a==42)
break;
{
b[p]=a;
p++;
}
}
for(int c=0;c<p;c++)
cout<<b[c];
getch();
}
what's the problem with this
what's the problem with this code ??
gives me wrong answer
#include<iostream>
using namespace std;
int main()
{
int test[100],i=0;
for(i=0;i<100;i++)
{
cin>>test[i];
if(test[i]==42)
{
cin>>test[++i];
break;
}
}
int j=i;
for(i=0;i<j;i++)
cout<<test[i]<<endl;
return 0;
@gunjan #include<stdio.h> int
@gunjan
#include<stdio.h>
int main()
{
int a;
while(1)
{
printf("%d",a);//printing garbage value?
scanf("%d",&a);
if(a=42)
break;
}
}
i m beginner help me out
@dhruv what's the problem
@dhruv
what's the problem with this code ??
gives me wrong answer
#include<iostream>
using namespace std;
int main()
{
int test[100],i=0;
for(i=0;i<100;i++)
{
cin>>test[i];
if(test[i]==42)
{
cin>>test[++i];
break;
}
}
int j=i;
for(i=0;i<j;i++)
cout<<test[i]<<endl;
return 0;
//its not neccessary to first print all input and then their respective output
you can do something like this..lets say user enter i/p x whose o/p is y
x
y(after pressing enter)
#include<stdio.h>void
#include<stdio.h>
void main()
{
int i;
while(1)
{
scanf("%d",&i);
if (i==42)
break;
else
printf("%dn",i);
fflush(stdin);
}
}
-- I have submitted above program but i got run time error without fflush(stdin) and got compilation error with that statement.
-- As our program is checked by some software. It might be using predefined inputs files for testing our program. It might be storing output to some other temporary file. And then might be comparing that with some permanent files for specific inputs file. So, if this is the case then it should give correct result.
-- Can anybody help me to understand the reason of errors I got or otherwise tell me what I am missing who so ever has successfully submited this program.
#include<stdio.h>void
#include<stdio.h>
void main()
{
int i;
while(1)
{
scanf("%d",&i);
if (i==42)
break;
else
printf("%dn",i);
fflush(stdin);
}
}
-- I have submitted above program but i got run time error without fflush(stdin) and got compilation error with that statement.
-- As our program is checked by some software. It might be using predefined inputs files for testing our program. It might be storing output to some other temporary file. And then might be comparing that with some permanent files for specific inputs file. So, if this is the case then it should give correct result.
-- Can anybody help me to understand the reason of errors I got or otherwise tell me what I am missing who so ever has successfully submited this program.
-- Is there any IDE which works similar to Software checking our problem.
//WHY IT IS RUNTIME ERROR? I
//WHY IT IS RUNTIME ERROR? I DID NOT GET............I APPRECIATE YOUR FEEDBACK..............
#include<stdio.h>
void main(){
int a[5];
int i;
for(i=0;i<5;i++){
scanf("%d",&a[i]);
}
//for comparision
for(i=0;i<5;i++){
if(a[i]==42)
break;
printf("n%d",a[i]);
}
}
#include<iostream.h> #include
#include<iostream.h>
#include<conio.h>
void main()
{
int i;
for(;;)
{
cin>>i;
if(i==42)
break;
cout<<i;
}
getch();
}
First Read FAQ!
First Read FAQ!
PLEASE TELL...WHY THIS CODE
PLEASE TELL...WHY THIS CODE IS NOT WORKING???
#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
int no;
struct node *link;
}node;
main()
{
int num;
node *temp,*start,*temp1;
temp=(node *)malloc(sizeof(node));
start=temp;
do
{
scanf("%d",&num);
if(num==42)
{
temp==NULL;
break;
}
else
{
temp->no=num;
temp1=(node *)malloc(sizeof(node));
temp->link=temp1;
temp=temp1;
}
}while(1);
temp=start;
while(temp!=NULL)
{
printf("%dn",temp->no);
temp=temp->link;
}
}
i''ve submitted the correct
i''ve submitted the correct code .....i've checked it twice but the submission is producing run time error....plz reply
This is my solution in
This is my solution in Java
public class Life{
public static void main(String[] args){
java.io.BufferedReader in = new java.io.BufferedReader (new java.io.InputStreamReader (System.in));
String str = in.readLine();
while(!str.startsWith("42"))
System.out.println(str);
}
}
#include<stdio.h> main(){ int
#include<stdio.h>
main()
{
int n,t;
while(t--)
{
scanf("%d",&n);
if (n==42)
{
break;
}
else
printf("%dn",n);
}
return 0;
}
The example was not clear
The example was not clear enough first. :)
#include<stdio.h> main(){ int
#include<stdio.h>
main()
{
int n,t;
while(t--)
{
scanf("%d",&n);
if (n==42)
{
break;
}
else
printf("%dn",n);
}
return 0;
}
import java.util.*; class
import java.util.*;
class TEST
{
public static void main(String args[])
{
Scanner s =new Scanner(System.in);
int x=s.nextInt();
while(x!=42)
{
System.out.println(x);
x=s.nextInt();
}
System.exit(1);
}
}
why isnt this not being accepted...???
#include<conio.h> #include<io
#include<conio.h>
#include<iostream.h>
main()
{
clrscr();
int a[5];
for(int i=0;i<5;i++)
{
cout<<"Enter The No."<<endl;
cin>>a[i];
}
for(int i=0;i<3;i++)
{
cout<<a[i]<<endl;
}
getch();
}
import java.util.*; class
import java.util.*;
class A
{
Scanner in=new Scanner(System.in);
int e[]=new int[10];
public void setArray()
{
for (int i=0; i<10; i++)
{
e[i]=in.nextInt();
}
System.out.println("n");
}
public void getArray()
{
for(int i=0; i<10; i++)
{
if (e[i]==42)
{
break;
}
System.out.println(e[i]);
}
}
public static void main(String a[])
{
A w=new A();
w.setArray();
w.getArray();
}
}
Can someone explain how to
Can someone explain how to write asm code for this problem?
Thanks
#include<stdio.h>int
#include<stdio.h>
int num[2];
int main()
{
int a;
int i;
i=0;
while(scanf("%d",&a)==1)
{
if(a == 42) break;
else num[i] = a;
i++;
}
for(i=0; i<sizeof(num); ++i)
{
if(num[i]== 0) break;
else printf("%dn",num[i]);
}
return 0;
}
why this code is not taken as the solution of this problem
Hey check me if i am wrong
Hey check me if i am wrong .....
The sample input output is displayed wrong...
it should be like this
Input: 4
Output: 4
Input: 56
Output: 56
Input: 32
Output: 32
Input: 87
Output: 87
Input: 42
right?
#include<conio.h>#include<ios
#include<conio.h>
#include<iostream.h>
void main()
{
int n;
cin>>n;
if(n!=42)
{
cout<<n;
}
getch();
}
#include<iostream.h>void
#include<iostream.h>
void main()
{
int n;
cin>>n;
if(n!=42)
{
cout<<n;
}
getch();
}
hahaha!!!! this is real
hahaha!!!!
this is real crap...
this question's solution as submitted by other users is literally wrong..
bcoz
see the input in question:
"1
Can anyone help me out with
Can anyone help me out with this problem?
:: CODE STARTS ::
<?php
while (true)
{
$line = fgets(fopen ("php://stdin','r'"));
if(trim($line) != '42')
{
echo trim($line) . 'n';
}
else
{
break;
}
}
?>
:: CODE ENDS ::
I am getting "Time Limit exceeded" after I submit the above code.
Can anyone point out, how can I optimize the code to make it work before the defined time limit?
Thanks in advance.
Regards,
Michael.
Anyways, I solved it!!!::
Anyways, I solved it!!!
:: Optimized CODE STARTS ::
<?php
while (1)
{
$line = trim(fgets(STDIN));
if($line != '42')
{
fwrite(STDOUT, $line."n");
}
else
{
break;
}
}
?>
:: CODE ENDS ::
Regards,
Michael.
plc tell me what is wrong
plc tell me what is wrong with this it gives run time error bt i cant figure it out.
#include <iostream>
using namespace std;
int main(void){
int inputNum = 0 , validater = 0;
while(true){
cin >> inputNum;
if(inputNum == 42)
validater = 1;
if(inputNum != 42 && validater == 0)
cout << inputNum << endl;
}
return 0;
}
plc tell me what is wrong
plc tell me what is wrong with this it gives run time error bt i cant figure it out.
#include <iostream>
using namespace std;
int main(void){
int inputNum = 0 , validater = 0;
while(true){
cin >> inputNum;
if(inputNum == 42)
validater = 1;
if(inputNum != 42 && validater == 0)
cout << inputNum << endl;
}
return 0;
}
@Chaminda Sampath in very 1st
@Chaminda Sampath
in very 1st line...
->#include<iostream.h>
#include <stdio.h> #include
#include <stdio.h>
#include <conio.h>
void main()
{
int i=0;
while ( i!= 42)
{
scanf ("%d", &i);
printf ("%d", i);
}
getch();
clrscr();
}
import
import java.util.Scanner;
class BruteForce
{
public static void main(String arg[])
{
int i=0;
int A[]=new A[99];
Scanner in=new Scanner(System.in);
System.out.println("enter any no in 2 digits max:");
while(i<=99)
{
if(A[i]!=42)
{
System.out.println(A[i]);
}
else
break;
}
}
}
#include<iostream.h> main() {
#include<iostream.h>
main()
{
int a[5];
for(int i=0;i<5;i++)
{
cout<<"Enter the 2 digit no. "<<i<<endl;
cin>>a[i]
}
for(i=0;i<5;i++)
{
if(a[i]!=45)
{
cout<<a[i]<<endl;
}
else
return 0;
}
}
#include<iostream.h> main() {
#include<iostream.h>
main()
{
int a[5];
for(int i=0;i<5;i++)
{
cout<<"Enter the 2 digit no. "<<i+1<<endl;
cin>>a[i];
}
for(i=0;i<5;i++)
{
if(a[i]!=45)
{
cout<<a[i]<<endl;
}
else
return 0;
}
}
#include<stdio.h>int
#include<stdio.h>
int main()
{
int x;
for(;;)
{
scanf("%d",&x);
if(x>0&&x<100&&x!=42)
printf("%dn",x);
else
break;
}
return 0;
}
//You should enter the number except the 42 then it will execute successfull
#include<stdio.h>void
#include<stdio.h>
void main()
{
int x;
for(;;)
{
scanf("%d",&x);
if(x!=42)
printf("%dn",x);
else
break;
}
}
import java.util.*;class
import java.util.*;
class BruteForce
{
public static void main(String []args)
{
Scanner kb=new Scanner(System.in);
int i,len=0,a[]=new int[30];
do
{
a[len]=kb.nextInt();
len=len+1;
}
while(a[len-1]!=42);
for(i=0;i<len-1;i++)
{
System.out.println(a[i]);
}
}
}
#include<iostream.h> #include
#include<iostream.h>
#include<conio.h>
int main()
{int a[100],i,ch;
{cout<<"enter the nos:n";
{
for(i=0;i<100;++i)
cin>>a[i];
if(a[i]==42)
break;
]
ch=i;
}
for(i=0;i<ch;++i)
cout<<"n"<<a[i];
getch();
}
#include<stdio.h> #include<co
#include<stdio.h>
#include<conio.h>
void main()
{
int a[100],i,n;
printf("enter the nos = ");
for(i=0;i<100;i++)
{
scanf("%d",&n)
if(n==42)
break;
a[i] = n;
}
n=i;
for(i=0;i<=n;++i)
printf("%dn"a[i]);
getch();
}
#include<iostream.h> #include
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,i=0;
while(i!=42)
cout<<i;
i++;
}
getch();
}
#include<iostream.h> #include
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,i=0;
while(i!=42)
{
cout<<i;
i++;
}
getch();
}
#include<stdio.h> int
#include<stdio.h>
int main()
{
int i
while(i!=42)
{
printf("enter a two digit number");
scanf("%d",&i);
printf("%d",i);
}
return 0;
}
class number { public static
class number
{
public static void main(String []s)
{
s[]={1,2,88,42,77};
for(int i=0;i<=s.length-2;i++)
{
System.out.println(s);
}
}
}
using System; using
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace democonsole
{
class Program
{
static void Main(string[] args)
{
int[] a = new int[5];
a[0] = 1;
a[1] = 2;
a[2] = 88;
a[3] = 42;
a[4] = 99;
System.Console.WriteLine("nn");
for (int i = 0; i < 4; i++)
{
if (a[i] != 42)
{
System.Console.WriteLine(a[i]);
}
else
break;
}
Console.ReadKey();
}
}
}
whats the error here mate any one
#include <stdio.h> #include
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i;
for(;;)
{
scanf("%d", &i);
if(i != 42)
{
printf("%dn", i);
}
else
{
return 0;
}
}
system("PAUSE");
}
void main(){ int i=0;
void main()
{
int i=0;
while(1)
{
printf("Enter your number");
scanf("%d",&i);
if(i==42)
break;
else
printf("%d",i);
}
}
#include "stdio.h" int
#include "stdio.h"
int main(){
int i;
for(;;){
scanf("%d", &i);
if(i != 42){
printf("%dn", i);
} else {
return 0;
}
}
}
#include<stdio.h> #include<co
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10]={0},i=-1,j;
do
{
scanf("%d",&a[++i]);
}while(a[i]!=42);
for(j=0;j<i;j++)
printf("%d",a[j]);
getch();}
whats the difference in
whats the difference in coding in turbo c++ and a gcc compiler i am not used to gcc compiler what are the things that i should atleast know to code in gcc compiler and compile my code?
Hii....I'm using Dev C++ for
Hii....
I'm using Dev C++ for coding problems....
Which Language I should select from the drop down menu for submitting the code on my profile....
there's no option for DEV C++....
I've compiled the code on my PC successfully.....
Please help me out....
@Prerit Anwekar - GCC
@Prerit Anwekar - GCC compiler is a Linux based editor for C++....
#include<stdio.h> #include<co
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
printf("ENTER NUMBER = n");
scanf("%d",i);
while(1)
{
if(i!=42)
printf("%d",i);
else
break();
}
}
#include<stdio.h> #include<co
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
printf("ENTER NUMBER = n");
scanf("%d",i);
while(1)
{
if(i!=42)
printf("%d",i);
else
break();
}
}
#include<stdio.h>int
#include<stdio.h>
int main(void)
{
unsigned int num;
int n;
printf("Enter no of integer: ");
scanf("%d",&n);
for(int i=0i<n;i++)
{
printf("Enter the 2 digit positive no. :");
scanf("%d",&num[i]);
if(num[i]>99 | num[i]<0)
{
printf("Error in input");
exit(0);
}
}
for(i=0i<n;i++)
{
printf("Enter 2 digit positive no.");
scanf("%d",&num[i]);
if(num[i]==42)
break;
}
return(0);
}
#include<stdio.h> int
#include<stdio.h>
int main()
{
int a;
for(;;)
{
cin>>a
if(a==42)
break;
else
cout<<a;
}
}
@Codechef, how do you check
@Codechef, how do you check the Mem?
I've submitted the same code in C as others with 0M did. But it shows me 1.6M? Why?
Is this something to do with browsers?
Please help, I've competition on 20th april and this will really help me.
import java.io.*; public
import java.io.*;
public class NewClass
{
public static void main(String args[])throws IOException
{
int a;
do{
DataInputStream in=new DataInputStream(System.in);
a=Integer.parseInt(in.readLine());
System.out.println(a);
} while (a != 42);
}
}
#include<stdio.h>#include<con
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("PLEASE ENTER ANY INTEGER NUMBER OF ONE OR TWO DISITS ");
do
scanf("%d",&n);
while(n!=42);
printf("nn42 found!!!nnPLEASE PRESS ANY KEY TO EXIT");
getch();
}
puts "Input integers of one
puts "Input integers of one or two digits separated by space."
input = gets.chomp
input.split(" ").each do |n|
exit if n.to_i == 42
puts n
end
ARGV.each do |n|
puts n
exit if n == 42
end
//Program for inputing 10
//Program for inputing 10 numbers at a time
//it terminates and print the entered numbers before the digit 42
import java.util.Scanner;
public class Test1
{
static Scanner sn=new Scanner(System.in);
public static void main(String[] args)
{
int[] arr=new int[10];
int num;
System.out.println("Enter two digit numbers:");
{
num=(int)Integer.parseInt(""+sn.next());
for(int i=0;i<arr.length;i++)
{
if(num!=42)
{
arr[i]=num;
num=(int)Integer.parseInt(""+sn.next());
}
else
break;
}
System.out.println("Entered numbers are:");
for(int i=0;i<arr.length;i++)
{
if(arr[i]!=42)
{
if(arr[i]==0)
{
break;
}
System.out.println(arr[i]);
}
else
{
break;
}
}
}
}
}
//It's Hp
import java.util.*; public
import java.util.*;
public class BruteForce
{
public static void main(String s[])
{
Scanner sc=new Scanner(System.in);
int i=0;
while(1)
{
i=sc.nextInt();
if(i==42)
break;
System.out.println(i);
}
}
}
this is the correct code in
this is the correct code in C
written in DEV C++ Compiler
frist time it wsnt accepted because i didnt choose the Language C in the submit page, so beaware..
#include<stdio.h>
//#include<conio.h>
int main()
{
int i;
while (scanf("%d",&i))
{
if (i==42)
{
break;
}
else
{
printf("%dn",i);
}
}
//getch();
return 0;
}
#include<stdio.h>int
#include<stdio.h>
int main()
{
int a;
for(;;)
{
scanf("%d",&a);
if(a!=42)
{
printf("%dn",a);
}
else
{
break;
}
}
}
WHATS WRONG WITH IT IAM GETTING RUNTIME ERROR
#include <stdio.h> int
#include <stdio.h>
int main()
{
int i =0;
}
#include <stdio.h> void
#include <stdio.h>
void main()
{
int i = 42;
scanf("%d", &i);
while( i != 42)
{
printf("%dn", i);
scanf("%d", &i);
}
}
You have asked that stop
i agree with surendargora i
how many inputs we have to
What is the time limit means
I tested sample solution it
#include int main() { int
nooo
can i know whats wrong with
@sravya give me your code
@hungry
@sravya cant u look at your
@hungry coder...yeah..i got
Thats the point and one more
void doesnt work fine coz gcc
void main(void) { int
seems like python programmers
wow...gr8 editor ^^...
@shatu_bits import sys
@nrkchaitanya... can you
import java.io.*; class
import java.io.*; class
what is wrong with my
#include int main() {
Whats wrong with this
import java.util.*; public
using System; using
using System; namespace
plz tell me the error in my
@prateekgupta: u r missing
#include main() { int
i hav run da code nd its
why runtime error for this
import
import
why runtime error for this
what is the problem here pls
pls help me to find the error
in this time limit exceed
http://www.codechef.com/views
SOMEONE PLZ HELP ME WITH THE
admin plz suggest somthing
@rahulkumar7887: you should
@bhanu compilation error is
please help this is my first
class Nnmber { public static
import java.util.*; public
whats error in
saurabhzx: > whats error in
#include int main() { int
Please can someone help as to
This is my first submission.
How come I can't submit the
can anyone tell what's the
#include void main(){ int
Why i use code on top , i get
Its showing run time
I am trying to upload the
#include #include void
This is my
import java.io.*; class
main() { unsigned int
#include #include void
#include #include void
Can anyone tell me why we'll
prachi namespace is used to
unable to get question :(
#include int
All persons who have
#include void main() { int
y m i gettin runtime error 4
#!/bin/bash for i in 1 2 88
#!/bin/bash for i in 1 2 88
#include int main() { int
Please help me. What is the
i have submitted the solution
#include void main() { int
please reply
please help me out i'm not
please help me out i'm not
#inlcude int main() { int
#include #include #include st
a
@rakesh_yadav: you have to
#include //#include int
#include int main (void)
hey i've a problem in self de
I am trying to write the code
Can anyone tell me WHY IS
#include void main() { int
#include #include void
#include #include void
#include #include void
Can anybody help why do i get
why it did get
class BruteForce { public
import java.io.*; class
(No subject)
/** * @(#)Solution.java *
#include int main() {int
#include "stdio.h" int
Hi, The following code is for
i tried out the sample code
#include main() {
can anyone tell me, i'm
#include int main() { int
#include main() { int
#include int main() {
how to enter my code and
where to get gcc versions or
How do you know when it ends?
"i tried out the sample code
This is STUPID!!! ALL my
Great the meaning of life is
i'm getting a run time error
#include main() { int
class abc {public static void
#include void main() { int
#include int main() { int
how am i wrong can anyone
#include int main() { int
Sir i have doubt in these
Why does it allow you to
it is not recognizing header
how is this
#include void main() { int
#include int main(){ int
#include int main(void) { int
what is compilation error all
this seems like mumbo jumbo
trambilas1244: last I heard,
my code is giving compiling
@codemink first check it on
why my prog is giving wrong
why it is not accepting the
#include int main() {int
could someone help me
Why am i getting a Run Time
my code is : #Python. I don't
Can anyone tell me whats
Been seeing "Oops, we
@suraj_subba : Dude u have
@suraj_subba: dont use
public static void
The program required is way
#include #include
#include int main() { int
#include int main(){ int
hey can u tell whts wrong in
hey whts wrong in
getting run time error for
import
why my code is wrong? class
#include int array(int); int
#include #include void
#include void
#include int main(void) {
using System; using
but the program says only
Well... a clear explanation
where is the problem
#include void main() { int
import java.util.*; class
Hey guys am new to this group
#include void main() {
hello sir, i tried solving
hi why i am getting error
#include #include void
http://www.codechef.com/views
I hav done my work on Turbo
Tel me the error in this prog
Tel me the error in this prog
I tried to post a solution to