Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int MAX_SIZE = 100;
- void swap(char str[], int index, int length)
- {
- while (index <= length)
- {
- char temp = str[index];
- str[index] = str[index + 1];
- str[index + 1] = temp;
- index++;
- }
- }
- int strLength(char str[])
- {
- int counter = 0;
- for (size_t i = 0; str[i] != '\0'; i++)
- {
- if (str[i] >= 33 && str[i] <= 125)
- counter++;
- }
- return counter;
- }
- void makeBigger(char str[],int &length)
- {
- bool flag = false;
- length = strLength(str);
- for (size_t i = 0; i <= length; i++)
- {
- if (str[i] == '[')
- {
- flag = true;
- swap(str, i, length);
- str[i] = str[i] - 32;
- continue;
- }
- if (str[i] == ']')
- {
- flag = false;
- swap(str, i, length);
- continue;
- }
- if (flag)
- {
- str[i] = str[i] - 32;
- }
- }
- }
- int main()
- {
- char str[MAX_SIZE];
- cout << "Enter your sentence: " << endl;
- cin.getline(str, 99);
- int length = 0;
- length = strLength(str);
- makeBigger(str, length);
- for (size_t i = 0; i < length; i++)
- {
- cout << str[i];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement