Advertisement
Guest User

Untitled

a guest
Feb 27th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <locale>
  3. #include <windows.h>
  4.  
  5. using namespace std;
  6.  
  7. char* UpperW1251(char* source, char* destination, int arr_length){
  8. //int code = (int)('9'); // a=97 z=122 0=48 9=57; //а=-32 я=-1
  9. for (int i = 0; i < arr_length; i++){
  10. if (*source == '\0'){
  11. *destination = *source;
  12. break;
  13. }
  14. else{
  15. if ((int)*source == -72){
  16. *destination = (int)*source - 16;
  17. }
  18. else if (((int)*source >= 97 && (int)*source <= 122) || ((int)*source >= -32 && (int)*source <= -1)){
  19. *destination = (int)*source - 32;
  20. }
  21. else
  22. *destination = *source;
  23. }
  24. source++;
  25. destination++;
  26. }
  27. return destination;
  28. }
  29.  
  30. int main(int argc, char* argv[])
  31. {
  32. setlocale(LC_ALL, "");
  33. char source[] = "I'm ebal всех в рот, сука ёбаная!!!";
  34. int source_length = sizeof(source);
  35. char *pSource = source, *destination = new char[source_length];
  36. char *pDestination = destination;
  37. cout << "Исходная строка: ";
  38. for (int i = 0; i < source_length; i++){
  39. cout << *pSource;
  40. pSource++;
  41. }
  42. cout << endl;
  43. pSource = source;
  44. pDestination = UpperW1251(pSource, pDestination, source_length);
  45. pDestination = destination;
  46. cout << "Изменённая строка: ";
  47. for (int i = 0; i < source_length; i++){
  48. cout << *pDestination;
  49. pDestination++;
  50. }
  51. cout << endl;
  52. system("pause");
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement