Page 2 of 2

Re: 11878 - Homework Checker

Posted: Thu Nov 20, 2014 12:17 am
by Helaluddin_brur
thanks every body for kind help
got accepted now

Re: 11878 - Homework Checker

Posted: Thu Nov 20, 2014 2:33 pm
by lighted
Use code tags. You should print number of correct answers. You print answers that doesn't match. Problem description says
Print a single integer in a line, the number of correct answers
sohel wrote:Try this case

Code: Select all

1+1=?
Acc Output is 0.
Shahidul.CSE wrote:problem was that i didn't control when c<0

Code: Select all

Removed after accepted
brianfry713 wrote:1-2=-1
According to problem description input above is invalid. I didn't checked case when c < 0 and got accepted.
where a and b are numbers prepared by the teacher (they are guaranteed to be non-negative integers not greater than 100), c is the answer computed by your younger brother and is either a non-negative integer not greater than 200, or a single character `?' (that means, he is unable to compute the answer).

Re: 11878 - Homework Checker

Posted: Thu Nov 20, 2014 7:18 pm
by Shahidul.CSE
Dear Helaluddin_brur,
My 1st suggestion to you "please use code tag" to post your code in this forum, that means your code should start with "

Code: Select all

" and end with 
"
". You can easily use this by clicking on "Code" above the text box.

Now come to the point.
1) You are printing the correct ans when an answer is wrong, and are doing nothing when ans is correct. But in this problem you are asked to print the number of correct answer, that means you have to print "how many answer is correct". You should take a variable (say Count), and when an answer of your younger brother is correct, increment the value of the variable by 1(that means Count++).

2) I solved this problem by taking input as a single string for each line (i.e. using scanf("%s",&str);). By the way, I don't mean that you should use this approach, it just a hint.

3) remember that output will be just one integer indicating "how many ans are correct".

Hope this help. keep posting . Best of luck .

Re: 11878 - Homework Checker

Posted: Thu Nov 20, 2014 9:26 pm
by brianfry713
I deleted my invalid input: a, b, and c are non-negative in the judge's input.

Shahidul.CSE
char str[12];
scanf("%s", str) is correct
scanf("%s", &str) is wrong but works
http://stackoverflow.com/questions/5406 ... with-scanf

Re: 11878 - Homework Checker

Posted: Mon Nov 24, 2014 11:34 am
by mpmohi
Hi ,
I've got accepted this prob but I have a confusion that is "HOW this program stop taking input"
I use codeblocks and when I run this program it continuously taking input (unless i give a wrong sequence of input ,say ?+?=3) and never showing output .

I'm giving my code for your testing.

Code: Select all


Got it

Thanks in advance..

Re: 11878 - Homework Checker

Posted: Tue Nov 25, 2014 12:04 am
by brianfry713

Re: 11878 - Homework Checker

Posted: Tue Nov 25, 2014 5:56 am
by mpmohi
Thank you "brainfry713"

Re: 11878 - Homework Checker

Posted: Thu Oct 06, 2016 9:26 am
by altair_ibn_la_ahad
Can a '-' be appeared between '=' and 'c'. If can how should i treat it ? As invalid input ? And should i print a new line after ans ? uDebug seems to treat "1-2=-1" as a correct ans & put a new line after that.

Re: 11878 - Homework Checker

Posted: Fri Mar 10, 2017 3:08 pm
by lighted
Problem description says
c is the answer computed by your younger brother and is either a non-negative integer
So '-' can not be appeared. Yes, you should print a new line after answer. Otherwise you'll get wa.