why am i getting WA??
question-link text
solution-link text
solution : CodeChef: Practical coding for everyone
mistake :
for(i=1;i<=n;++i) cin>>a[i];
sort(a,a+n);
sort() sorts from a[0] to a[n-1] and your input is from a[1] to a[n]
https://www.codechef.com/viewsolution/14313839
question: life the universe the everthing
#include <stdio.h>
int main(void)
{
int i;
while (1) {
scanf(“%d”, &i);
if (i == 42)
break;
printf(“%d”, i);
}
return 0;
}
https://www.codechef.com/viewsolution/14319887
whats wrong with this code
it says time limit exceeded
thanks!!!
You are not printing each number in new line.
Add ‘\n’ in printf statement.
Thanks
First of all your array size if not according to constraint
Also, your logic doesn’t seem correct to me.Modify it.