0

How can I fix this problem?

Problem link: Problem link: https://www.sololearn.com/coach/73?ref=app My code link: https://code.sololearn.com/ceG7aG86FBcS/?ref=app

12th Aug 2021, 5:37 AM
Md Abu Taher
Md Abu Taher - avatar
6 Réponses
+ 2
Md Abu Taher If this is for the code coach challenge, then you must also remove punctuation, which has not been allowed for in your concept. May I suggest you look into isalpha(), isdigit() & isspace()
12th Aug 2021, 9:52 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 6
Please change the tag to cpp instead of Python.
12th Aug 2021, 5:55 AM
Calvin Thomas
Calvin Thomas - avatar
+ 2
Rik Wittkopp Thanks But it seems wrong answer in test case no 1.
12th Aug 2021, 9:39 AM
Md Abu Taher
Md Abu Taher - avatar
+ 2
Rik Wittkopp Many many thanks for your suggestion 🖤
12th Aug 2021, 10:14 AM
Md Abu Taher
Md Abu Taher - avatar
+ 1
Hmmm! Let me look a bit more
12th Aug 2021, 9:46 AM
Rik Wittkopp
Rik Wittkopp - avatar
0
Md Abu Taher I don't know enough about c++ to say why your ceil() func did not work, but I fixed some of the other problems and attached a little ceil() func to make it run. #include <bits/stdc++.h> using namespace std; int ceil(int x, int y){ if(x % y == 0){ return x/y; } else { return x/y +1; } } int main() { string s; getline(cin,s); int len = s.length(); int count=0; for(int i=0; i<len; i++){ if(s[i]!=' ') count++; } int word=1; for(int i=0; i<len; i++){ if(s[i]==' '){ word++; } } cout<< ceil(count,word); return 0; } //this code is working now
12th Aug 2021, 9:27 AM
Rik Wittkopp
Rik Wittkopp - avatar