Programming_Course1_Session2/18/Lab18/Lab18.cpp

32 lines
679 B
C++
Raw Normal View History

2023-03-09 00:04:11 +02:00
#include <iostream>
#include <string>
#include <ctype.h>
#include <windows.h>
using namespace std;
// Тут не використано <string.h>, бо оновлена <ctype.h> прекрасно працює з цим
int main() {
SetConsoleOutputCP(CP_UTF8);
string input;
cout << "Введіть строку: ";
getline(cin, input);
if (isupper(input[0])) {
for (int i = 0; i < input.length(); i++) {
input[i] = toupper(input[i]);
}
}
else {
for (int i = 0; i < input.length(); i++) {
input[i] = tolower(input[i]);
}
}
cout << "Result: " << input << endl;
return 0;
}