#include <iostream>
#include <string>
#include "pch.h"
using namespace std;
string find_words(string str, int a) {
int i;
int idx = 1;
for (i = 0; i < a; i++) {
if (str.at(i) == ' ') {
cout << endl;
idx++;
}
else {
cout << str[i];
}
}
cout << endl << idx << endl;
return 0;
}
int main(int argc, const char *argv[]) {
string str;
int num, f;
while (1) {
getline(cin, str);
f = str.find("Q");
if (f != -1) {
break;
}
else {
num = str.size();
cout << find_words(str, num);
}
return 0;
}
}
I don't think you need to pay much attention. If you're not going to release it, wouldn't it be okay to just get the input and output right?
Why does the return type of the function find_words return 0 when it is a string? If you don't have anything to return, change it to void
© 2024 OneMinuteCode. All rights reserved.