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
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()
+ 6
Please change the tag to cpp instead of Python.
+ 2
Rik Wittkopp
Thanks
But it seems wrong answer in test case no 1.
+ 2
Rik Wittkopp
Many many thanks for your suggestion 🖤
+ 1
Hmmm!
Let me look a bit more
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