Guest User

Untitled

a guest
Jan 12th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include<cstdlib>
  4. #include<cmath>
  5. #include<ctime>
  6. #include<string>
  7. using namespace std;
  8.  
  9. /*-------------------------------ZAD1
  10. string usunto(string a,string b)
  11. {
  12. string c;
  13. c=a+b;
  14. return c;
  15. }
  16.  
  17. int main()
  18. {
  19. string a,b,c;
  20. getline(cin,a);
  21. getline(cin,b);
  22. c=usunto(a,b);
  23. cout<<endl<<c<<endl;
  24. system("pause");
  25. }
  26. -------------------------------ZAD1*/
  27.  
  28.  
  29. /*-------------------------------ZAD2
  30. string usunto(string a,char b)
  31. {
  32. for(int i=0;i<a.length();i++)
  33. {
  34. if(a.at(i)==b)
  35. {
  36. a.erase(i,1);
  37. i--;
  38. }
  39. }
  40. return a;
  41. }
  42.  
  43. int main()
  44. {
  45. string a,b;
  46. char c;
  47. getline(cin,a);
  48. cin>>c;
  49. b=usunto(a,c);
  50. cout<<endl<<b<<endl;
  51. system("pause");
  52. }
  53. -------------------------------ZAD2*/
  54.  
  55.  
  56. /*-------------------------------ZAD3
  57. string dodaj(string a)
  58. {
  59. for(int i=0;i<a.length();i++)
  60. {
  61. if(a.at(i)=='a')
  62. {
  63. a.insert(i,1,',');
  64. i++;
  65. }
  66. }
  67. return a;
  68. }
  69. int main()
  70. {
  71. string a,b;
  72. getline(cin,a);
  73. b=dodaj(a);
  74. cout<<endl<<b<<endl;
  75. system("pause");
  76. }
  77. -------------------------------ZAD3*/
  78.  
  79.  
  80.  
  81.  
  82. /*
  83. void sort(string *a[],int b)
  84. {
  85. for (int l=1;l>0;)
  86. {
  87. l=0;
  88. for(int i=0;i<b;i++)
  89. {
  90. for(int j=0;j<a[i].length();j++)
  91. if(a[i].at(j)>a[i].at(j+1))
  92. {
  93. swap(a[i],a[i+1])
  94. l++;
  95. }
  96.  
  97. }
  98.  
  99.  
  100.  
  101.  
  102.  
  103. }
  104.  
  105. }
  106.  
  107. int main()
  108. {
  109. int a;
  110. cout<<"Wprowadz ilosc imion: ";
  111. cin>>a;
  112. cout<<endl;
  113. string *tab= new string[a];
  114. cout<<"Wprowadz imiona: "<<endl;
  115. for(int i=0;i<a;i++)
  116. {
  117. getline(cin,tab[i]);
  118. }
  119. string *tab2= new string[a];
  120. tab2=sort(tab[],a);
  121. for(int i=0;i<a;i++)
  122. {
  123. cout<<tab2[i]<<endl;
  124. }
  125. system("pause");
  126.  
  127.  
  128.  
  129. delete [] tab;
  130. delete [] tab2;
  131. }
  132.  
  133.  
  134. */
  135.  
  136.  
  137. /*-------------------------------ZAD5
  138. void palin(string a)
  139. {
  140. int d=a.length()-1;
  141. for(int i=0;i!=d;i++,d--)
  142. {
  143. if(a[i]!=a[d])
  144. {
  145. cout<<"Ten wyraz nie jest palindromem"<<endl;
  146. system("pause");
  147. exit(0);
  148. }
  149. }
  150. cout<<"Ten wyraz jest palindromem"<<endl;
  151. system("pause");
  152. }
  153.  
  154. int main()
  155. {
  156. string a;
  157. getline(cin,a);
  158. palin(a);
  159. }
  160. -------------------------------ZAD5*/
Advertisement
Add Comment
Please, Sign In to add comment