Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <cstdlib>
- #include <iostream>
- #include <string>
- #include <locale.h>
- #include <windows.h>
- using namespace std;
- void Get_String(char **str, int clear_str);
- bool Is_Empty(char **str, int clear_str);
- int Length_Str(char buffer[]);
- void Swap(char **str, int index);
- void Sort(char **str, int N);
- void Array_Initialization(int *array, int N);
- int Get_Index(int N);
- int Average(int *array, int N);
- void Zeroes_Initialization(int *array, int N, int M, int average);
- void Print_Array(int *array, int N);
- int Get_Array_Length();
- int Get_Array_Index(int N);
- int main() {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- setlocale(LC_ALL, "Russian");
- int word_num=0;
- int sp_num=3;
- int str_len=200;
- char key;
- do {
- char **strings = new char*[2];
- int N = 2, clear_str = 0;
- do {
- system("cls");
- while (clear_str != N) {
- Get_String(strings, clear_str);
- if (Is_Empty(strings, clear_str)) {
- cout << "You have entered an empty line repeat\n";
- }
- else {
- clear_str++;
- }
- }
- cout << "Press Space if you want to exit or any another key to add new string\n";
- key = getchar();
- if (key != 32) {
- N++;
- strings = (char **)realloc(strings, N * sizeof(char**));
- }
- getchar();
- } while (key != 32);
- for (int i = 0; i < (N); i++) {
- str_len = strlen(strings[i]); printf(" ");
- for (int j = 1; j < str_len; j++) {
- if ((strings[i][j - 1] != 32 && strings[i][j - 1] != 10) && (strings[i][j] == 32 || strings[i][j] == 10)) {
- word_num++;
- }
- cout << strings[i][j-1]; //вывод слов
- if ((word_num % sp_num == 0)&&(word_num!=0)) {
- printf(" END\n "); // проверка на деление
- word_num = 0;
- }
- }
- }
- for (int i = 0; i < N; i++) {
- free(strings[i]);
- }
- free(strings);
- cout << "Press Space if you want to exit\n";
- key = getchar();
- getchar();
- }while (key != 32);
- cout << "End\n";
- //second problem
- system("Pause");
- return 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement