getting wrong answer in number tower question

In my solution I have written

#include<stdio.h>
int main()
{
   int num;
   while(scanf("%d",&num)==1)
   {
     printf("%d",num);
   }
   return 0;
}

I don’t know where I am going wrong .

Can you add link to the problem…

www.codeshef.com/WORKSHOP

Stop trolling. This problem does’nt exist.

1 Like

http://www.codechef.com/WORKSHOP/problems/START02/ it does exist.

2 Likes

Rewrite this statement-> printf("%d",num); as printf("%d\n",num); and you get AC :slight_smile:

4 Likes

he is right the time limit is 1 sec which exceeded

can u provide the link to the question you are asking about?

@arun_as:

thnx bro :slight_smile:

Don’t know why it shows runtime error(NZEC) always.
here is my code in python:
while 1:
x=int(raw_input())
print x

Why am I getting wrong answer for the following code, can anyone help me with it please?

/* A program to take inputs*/

#include
#include
using namespace std;

int main()
{
int n;
register int c;
while(c!=EOF)
{
n=0;
c=getchar_unlocked();
for(;c>47&&c<58; c=getchar_unlocked())
{
if(c==47)
z=1;
n=(n<<1)+(n<<3)+c-48;
}
printf("%d\n",n);
}
return 0;
}

sorry, this is is the modified code:

/* A program for Number Tower*/

#include
#include
using namespace std;

int main()
{
int n;
register int c;
while(c!=EOF)
{
n=0;
c=getchar_unlocked();
for(;c>47&&c<58; c=getchar_unlocked())
{
n=(n<<1)+(n<<3)+c-48;
}
printf("%d\n",n);
}
return 0;
}