Why my cost fail in paint cost test | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Why my cost fail in paint cost test

#include <iostream> #include<math.h> using namespace std; int main() { int a; float b = 40.00; float c = 5.00; cin>>a; std::cout<<ceilf((b+c*a)/10+b+c*a); return 0; }

27th Feb 2020, 12:32 PM
Hiįŗæu VƵ Trįŗ§n Minh
Hiįŗæu VƵ Trįŗ§n Minh - avatar
2 Respostas
+ 4
I had exactly same problem šŸ˜ Then I just replaced ceil with round (you are using ceilf btw) and casted value to int before printing to console. generally it was like : cout << (int) round(that formula); That worked šŸ™„
27th Feb 2020, 1:15 PM
šŸ‡®šŸ‡³OmkaršŸ•‰
šŸ‡®šŸ‡³OmkaršŸ•‰ - avatar
+ 1
I recommend to use: float a; and 10.0 instead 10
27th Feb 2020, 4:26 PM
JaScript
JaScript - avatar