Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void russianCorrection(char* str)
- {
- for (int i = 0; i < (int)strlen(str); i++)
- {
- if (((str[i] >= -96) && (str[i] <= -81)) || ((str[i] >= -128) && (str[i] <= -97))) str[i] += 64;
- else
- {
- if ((str[i] >= -32) && (str[i] <= -17)) str[i] += 16;
- else
- {
- if (str[i] == -15) str[i] = -72;
- if (str[i] == -16) str[i] = -88;
- }
- }
- }
- }
- bool checkInputedString(char* str)
- {
- int a = strlen(str);
- if (a > 300) return false;
- for (int i = 0; i < a; i++)
- {
- if ((str[i] < 32) && (str[i] >= 0)) return false;
- }
- return true;
- }
- void inputStringAsciiCorrect(char* *pSource)
- {
- char * temp = (char*)malloc(301*sizeof(char));
- temp = (char*) memset(temp, NULL, 1);
- for (size_t i = 0; i < strlen(*pSource); i++)
- {
- if (((*pSource[i])>31) || ((*pSource[i])<0))
- {
- strncat(temp, &(*pSource)[i], 1);
- }
- }
- free(*pSource);
- *pSource = temp;
- }
- void cesarCorrect(char* str)
- {
- for (size_t i = 0; i < strlen(str); i++)
- {
- if (str[i]>-96)
- {
- if (str[i]<125)
- str[i] += 3;
- else str[i] = str[i] - 223;
- }
- }
- }
- int main(int argc, char* argv[])
- {
- setlocale(0, "ru");
- char* *str;
- char* source = (char*)malloc(sizeof(char)* 301);
- str = &source;
- if (argc == 1)
- {
- int i = 0;
- printf("input string: \n");
- gets(*str);
- int t = *str[i] - 0;
- std::cout << *str << std::endl;
- std::cout << t << std::endl;
- russianCorrection(*str);
- t = *str[i] + 0;
- std::cout << t << std::endl;
- if (!checkInputedString(*str))
- {
- inputStringAsciiCorrect(str);
- //i++;
- }
- cesarCorrect(*str);
- printf(*str, "/n\n");
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement