Answer the question
In order to leave comments, you need to log in
C++ error while executing a program, how to fix it?
// ConsoleApplication3.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
//
#include "pch.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s;
getline(std::cin, s);
int probel = 0;
//Перед или после запятой пробел не ставится.
for (int i = 0; i < s.size(); i++)
{
if (s[i]==' '|| s[i]==',')
{
probel++;
}
}
int massiv = 0;
string strochka = "";
string *a = new string[probel];
for (int i = 0; i < s.size(); i++)
{
if (s[i] != ' ' && s[i] != ','&&s[i]!='.'&&s[i]!='?'&&s[i]!='!')
{
strochka += s[i];
}
else
{
a[massiv] = strochka;
strochka = "";
massiv++;
}
}
for (int i=0;i<probel;i++)
{
cout << a[i] << endl;
}
cout << probel<<"\t"<<sizeof(s);
system("Pause");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question