c++急救 编程题

2024-12-22 01:54:17
推荐回答(2个)
回答1:

#include
#include
using namespace std;
int main(){
string number;
while(getline(cin,number)){
int a=0;
for(int i=0;i if(number[i]==' '){
a++;
}
}
cout<<++a< }
return 0;
}

#include
#include
#include
using namespace std;

int main() {
string number;
while (getline(cin, number)) {
int a = 0;
for (int i = 0; i < number.size() - 1; i++) {
if (isdigit(number[i]) && !isdigit(number[i+1])) {
a++;
}
}
if (isdigit(number[number.size() - 1])) {
a++;
}
cout << a << endl;
}
return 0;
}

回答2:

为什么自己不先试试呢!?