Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- void removeSpaces(string *pstr) {
- string line = *pstr;
- bool bFlag = true;
- int i, j, k;
- for (i = 0; line[i] != '\0'; i++) {
- if (line[i] == ' ') {
- for (j = 0; line[i + j] != '\0' && bFlag; j++) {
- if (line[i + j] != ' ') bFlag = false;
- }
- if (1 < j) {
- for (k = i + 1; line[k + j - 2] != '\0'; k++) line[k] = line[k + j - 2];
- line[k] = '\0';
- }
- bFlag = true;
- }
- }
- }
- void remopestring(string *pstr) {
- string line = *pstr;
- int pos = 0, i;
- for (i = 0; i < line[i] != '\0'; i++) {
- if (line[i] == ' ') {
- i++;
- pos = i;
- }
- else {
- if (isalpha(line[i])) {
- line[i] = toupper(line[i]);
- break;
- }
- }
- }
- for (i = pos; i < line[i] != 0; i++) {
- if (line[i] == '.' || line[i] == '!' || line[i] == '?') {
- i++;
- while (line[i] == ' ') i++;
- line[i] = toupper(line[i]);
- }
- }
- }
- int main() {
- setlocale(LC_ALL, "ru");
- string str;
- ifstream file("text1.txt");
- ofstream fout("text2.txt");
- if (file.is_open()) {
- while (!file.eof()) {
- getline(file, str);
- removeSpaces(&str);
- remopestring(&str);
- fout << str;
- }
- }
- //removeSpaces();
- //remopestring();
- // paragraphs();
- file.close();
- fout.close();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement