Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- #include <windows.h>
- #include <stdio.h>
- #include <cstdio>
- int main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- setlocale(LC_ALL, "Russsian");
- int qunter = 0;
- char str[80];
- printf("Введите предложение:\n");
- std::cin.getline(str, 80);
- ////////////////////////////////////////////////
- //Задание 1/////////////////////////////////////
- ////////////////////////////////////////////////
- for (int i = 0; i < 80; i++)
- {
- if ((str[i+1] == '\0' or str[i + 1] == ' ') and str[i] == 'а')
- {
- qunter++;
- }
- }
- if (!qunter)
- {
- printf("Нет таких слов\n");
- }
- else
- {
- printf("Найдено слов %d\n", qunter);
- }
- ////////////////////////////////////////////////
- //Задание 2/////////////////////////////////////
- ////////////////////////////////////////////////
- char buff[80];
- printf("Введите предложение:\n");
- std::cin.getline(str, 80);
- qunter = 0;
- for (int i = 0, j=0; i < 80; i++)
- {
- if (str[i] == '\0' or str[i] == ' ')
- {
- if (qunter == 0)
- {
- printf("Результат:\n");
- qunter = 1;
- }
- for (int k = 0; k < j; k++)
- {
- printf("%c",buff[k]);
- }
- printf("\n");
- j = 0;
- }
- else
- {
- buff[j] = str[i];
- j++;
- }
- }
- if (qunter == 0)
- {
- printf("Вы не ввели слов");
- }
- }
- int main()
- {
- ////////////////////////////////////////////////
- //Задание 3/////////////////////////////////////
- ////////////////////////////////////////////////
- char str[80];
- char buff[80];
- char buff1[80];
- char buff2[80];
- printf("Введите имя файла\n");
- gets(str);
- int len = strlen(str);
- if (len == 0)
- {
- printf("Некоретный ввод\n");
- }
- else
- {
- for (int i = len - 1; i >= 0; i--)
- {
- if (str[i] == '.')
- {
- strcpy(str+i+1, "exe\n");
- break;
- }
- if (str[i] == '\\' && len!=1)
- {
- strcat(str, ".exe\n");
- break;
- }
- if(i==0 && str[i] != '\\')
- {
- strcat(str, ".exe\n");
- }
- }
- puts(str);
- }
- ////////////////////////////////////////////////
- //Задание 4/////////////////////////////////////
- ////////////////////////////////////////////////
- printf("Введите ФИО\n");
- gets(str);
- len=strlen(str);
- int qunter=0;
- for(int i=0,j=0;i<len;i++)
- {
- if (str[i] == ' ')
- {
- if(qunter==0)
- {
- strcpy(buff1,buff);
- j = 0;
- qunter++;
- } else if(qunter==1)
- {
- strcpy(buff2,buff);
- j=0;
- qunter++;
- }
- }
- else
- {
- buff[j] = str[i];
- j++;
- }
- }
- printf("Привет, %s %s\n",buff2,buff1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement