|
|
back to boardproblem 1000 (a+b) Posted by wardun 21 Mar 2013 17:28 why wrong answer? #include<stdio.h> int main() {float a,b,sum; printf("a:");scanf("%f",&a); printf("b:");scanf("%f",&b); sum=a+b; printf("a+b:%f",sum); return 0;} Re: problem 1000 (a+b) Even i got the wrong answer . On a glance at your code if you give input as 1 and c ( letter ) you get a result 39 .which according to the problem statement is incorrect. It is concerned about addition of number so add test cases like checking whether input is valid for program . Edited by author 01.04.2013 15:28 Re: problem 1000 (a+b) You mustn't print any prompts. For example: "a: " or "b: ". Also you only must make the sum of two INTEGER numbers. Is no necessary to use float, only use int. Re: problem 1000 (a+b) You have been already informed that no prompts allowed. Another note - are you sure you can use "float" type? In example ( http://acm.timus.ru/help.aspx?topic=cpp) int is used instead. Float has less mantissa size - can be WA on big integers (big means "> 2^24"). Checked your solution locally and via online judge - answer for test is "6.000000", expected answer is 6, WA1. Edited by author 16.02.2016 14:48 |
|
|