Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. // ConsoleApplication4fff.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. /// /0 az do : 1 zadanie
  5. ///
  6. /// zadanie 3 wskaznik do 1 i odnosnik do 2 - wartosc piatki do odnosnika referencyjnego i wypisujemy wszystkie zmienne
  7. /// zadanie 4: wskaznik pokazujacy ostatni element i pierwszy element - petla sumujaca elementy tablicy
  8. /// zadanie 5: nullptr
  9. /// zadanie 6:
  10. #include "pch.h"
  11. #include <iostream>
  12.  
  13. int mystrlen2(char* tablica) {
  14. int tmp = 0;
  15.  
  16. while (tablica[tmp] != '\0')
  17. tmp++;
  18. return tmp;
  19. }
  20.  
  21. int mystrlen(char* tablica) {
  22. int counter = 0;
  23. char* tmpref = &tablica[0];
  24.  
  25. do {
  26. tmpref + 1;
  27. counter++;
  28. } while (tmpref[counter] != '\0');
  29.  
  30.  
  31.  
  32.  
  33. return counter;
  34.  
  35. }
  36.  
  37.  
  38. bool isPalindrom2(char* tablica) {
  39. int tmp = 0;
  40. int lettercounter = 0;
  41. while (tablica[tmp] != '\0')
  42. tmp++;
  43. int size = tmp;
  44.  
  45.  
  46. for (int i = 0; i < size; i++)
  47. if (tablica[i] == tablica[(size - 1) - i]) {
  48. lettercounter++;
  49. }
  50.  
  51. if (lettercounter == size) {
  52. return true;
  53. }
  54. else {
  55. return false;
  56. }
  57.  
  58. }
  59.  
  60.  
  61.  
  62. int main()
  63. {
  64. using std::cout;
  65. using std::endl;
  66.  
  67.  
  68. char tab1[] = "toot", *pt, *ptq;
  69. char tab2[] = "spook";
  70. char* ptr, *ptr2;
  71. ptr = tab1;
  72. ptr2 = tab2;
  73. pt = &tab1[0];
  74. ptq = tab1;
  75. cout << ptr << endl;
  76.  
  77. cout << "metoda artymetyki: " << mystrlen(ptr) << endl;
  78. cout << mystrlen2(ptr);
  79. cout << endl;
  80. cout << isPalindrom2(tab1);
  81. cout << endl;
  82. cout << isPalindrom2(tab2);
  83.  
  84.  
  85. int x, y;
  86. x = 5;
  87. y = 8;
  88.  
  89. cout <<
  90.  
  91.  
  92. }
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115. // Run program: Ctrl + F5 or Debug > Start Without Debugging menu
  116. // Debug program: F5 or Debug > Start Debugging menu
  117.  
  118. // Tips for Getting Started:
  119. // 1. Use the Solution Explorer window to add/manage files
  120. // 2. Use the Team Explorer window to connect to source control
  121. // 3. Use the Output window to see build output and other messages
  122. // 4. Use the Error List window to view errors
  123. // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
  124. // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement