Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. // ConsoleApplication2.cpp: определяет точку входа для консольного приложения.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <string>
  6. #include "iostream"
  7.  
  8. using namespace std;
  9. int main()
  10. {
  11.  
  12. string s1;
  13. string s2("ABC");
  14. string s3("ABCDF");
  15. string s4(s2);
  16. cout << s2 << endl;
  17. cout << s3 << endl;
  18. cout << s4 << endl;
  19. s1 = "GFFF";
  20. s2 = 'x';
  21. s3 = "123456";
  22. s4 = s3;
  23. cout << s1 << endl;
  24. cout << s2 << endl;
  25. cout << s3 << endl;
  26. cout << s4 << endl;
  27. cin >> s1;
  28. getline(cin, s1);
  29. cout << s1<<endl;
  30.  
  31. cin.get();
  32. cout << "vvedite text" << endl;
  33. getline(cin, s2);
  34. cout << s1 << endl;
  35. cout << s2 << endl;
  36. s1 = "what?";
  37. s2 = "where?";
  38. s3 = "when?\n";
  39. string s5 = s1 + s2 + s3;
  40. s5 += s3;
  41. cout << s5 << endl;
  42.  
  43.  
  44. s1 = "abc";
  45. s2 = "bcd";
  46. cout<<(s1 == s2) << endl;
  47. s2 = "kqwefpok";
  48. cout << (s1 < s2) << endl;
  49. s2 = "acc";
  50. cout << ("abc" < "acc") << endl;
  51.  
  52.  
  53. cout << "dlina s5=" << s5.size() << endl;
  54. cout << s5.max_size() << endl;
  55. cout << s5.capacity() << endl;
  56. for (int i = 0; i < s5.size(); i++)
  57. {
  58. cout << s5;
  59. }
  60. string s7;
  61. cout << s7.capacity() << endl;
  62. s5.erase(4, 4);
  63. cout << s5 << endl;
  64. cout << s5.size() << endl;
  65. s5.erase(10, 6);
  66. cout << s5 << endl;
  67.  
  68. s5.insert(4, "where?");
  69. cout << s5 << endl;
  70.  
  71. s5.push_back('!');
  72. cout << s5 << endl;
  73.  
  74. s5.erase();
  75. cout << s5 << endl;
  76. if (s5.empty())
  77. {
  78. cout << "pusto\n";
  79. }
  80. else {
  81. cout << "ne gusto\n";
  82. }
  83.  
  84. cout << s5.max_size() << endl;
  85.  
  86.  
  87. for (char ch = 'a'; ch <= 'z'; ++ch)
  88. s5.push_back(ch);
  89.  
  90.  
  91. string::size_type indx;
  92. s5 = "WHEEEEEEEEN?";
  93.  
  94. s5 = s5 + s3;
  95. cout << s5 << endl;
  96.  
  97. cout << s5 << endl;
  98. indx = s5.find(s3);
  99. cout << s5.find("AAA");
  100. cout << indx << endl;
  101.  
  102. s5 = "123,45";
  103. string::size_type kod;
  104. double xx = stod(s5, &kod);
  105.  
  106. if (s5.size() == kod)
  107. cout << kod << endl;
  108. else
  109. cout << "Error" << endl;
  110.  
  111.  
  112.  
  113.  
  114.  
  115. system("pause");
  116. return 0;
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement