11878 - Homework Checker

All about problems in Volume 118. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Helaluddin_brur
New poster
Posts: 15
Joined: Tue Oct 21, 2014 4:08 pm
Location: Bangladesh
Contact:

Re: 11878 - Homework Checker

Post by Helaluddin_brur » Thu Nov 20, 2014 12:17 am

thanks every body for kind help
got accepted now
Last edited by Helaluddin_brur on Thu Nov 20, 2014 9:39 pm, edited 2 times in total.

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 11878 - Homework Checker

Post by lighted » Thu Nov 20, 2014 2:33 pm

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).
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

Shahidul.CSE
Experienced poster
Posts: 148
Joined: Sun Jul 13, 2014 4:32 am
Location: Rangpur, Bangladesh
Contact:

Re: 11878 - Homework Checker

Post by Shahidul.CSE » Thu Nov 20, 2014 7:18 pm

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 .
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11878 - Homework Checker

Post by brianfry713 » Thu Nov 20, 2014 9:26 pm

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
Check input and AC output for thousands of problems on uDebug!

mpmohi
New poster
Posts: 13
Joined: Wed Feb 26, 2014 10:15 pm

Re: 11878 - Homework Checker

Post by mpmohi » Mon Nov 24, 2014 11:34 am

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..
Last edited by mpmohi on Tue Nov 25, 2014 5:49 am, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11878 - Homework Checker

Post by brianfry713 » Tue Nov 25, 2014 12:04 am

Check input and AC output for thousands of problems on uDebug!

mpmohi
New poster
Posts: 13
Joined: Wed Feb 26, 2014 10:15 pm

Re: 11878 - Homework Checker

Post by mpmohi » Tue Nov 25, 2014 5:56 am

Thank you "brainfry713"

altair_ibn_la_ahad
New poster
Posts: 2
Joined: Thu Jun 09, 2016 12:01 pm

Re: 11878 - Homework Checker

Post by altair_ibn_la_ahad » Thu Oct 06, 2016 9:26 am

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.

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 11878 - Homework Checker

Post by lighted » Fri Mar 10, 2017 3:08 pm

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.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

Post Reply

Return to “Volume 118 (11800-11899)”

Who is online

Users browsing this forum: No registered users and 1 guest