Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by 7,2 ( 14 years ago )
#include <iostream>
#include <conio.h>
#include <string.h>
#include <ctype.h>
using namespace std;
const int m=81;
int input_mas(char **mas, int n)//Ввод массива
{
int k=0;
while (k<n)
{
cin.getline(mas[k],m-1);
if ((strcmp(mas[k],"")==0)) break;
k++;
}
return k;
}
void print_mas(char **mas, int n)// Печать массива
{
cout<<"Введенный массив строк:"<<endl;
for (int i=0; i<n; i++)
cout<<mas[i]<<endl;
}
void print_kol(char **mas, int n) // количество слов
{
int q;
cout<<" количество букв:"<<endl;
cin>>q;
for(int i = 0; i< n; i++)
{
for(int j = 0; j<strlen(mas[i]); j++)
{
if(!j || mas[i][j-1] == ' ')
{
char b[81];
int k = 0;
while(!isspace(mas[i][k]) && !ispunct(mas[i][k]))
{
b[k]=mas[i][k+j];
k++;}
b[k]='\0';
if(k>q)
cout<<b<<", ";
j+=k-1;
cout<<k<<endl;}}}
}
void main()
{
setlocale(LC_ALL,"");
const int n=10;
char **mas; // Динамический двумерный массив символов, т.е. массив указателей на строки
mas=new char *[n];// Выделение места в памяти под n строк
for (int i=0; i<n; i++) mas[i]=new char [m-1];
// Выделение места в памяти под m-1 символ в каждой строке
cout<<"Введите массив строк"<<endl;
int k=input_mas(mas,n);
print_kol(mas,k);
print_mas(mas,k);
getch();
}
Revise this Paste
Parent: 46725