Advertisement
Guest User

Untitled

a guest
May 29th, 2022
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. struct Adres {
  4. int Dom;
  5. const char* Ulitsa;
  6. const char* Gorod;
  7. int index;
  8. };
  9. int Index(Adres** arr, int size, int index) {
  10. for (int i = 0; i < size; i++)
  11. {
  12. if (arr[i]->index == index)
  13. cout << arr[i]->Dom << endl;
  14. if (arr[i]->index == index)
  15. cout << arr[i]->Ulitsa << endl;
  16. if (arr[i]->index == index)
  17. cout << arr[i]->Gorod << endl;
  18. }
  19. return 0;
  20. }
  21. int Adress(Adres** arr, int size, int Dom, const char* Ulitsa, const char* Gorod)
  22. {
  23. for (int i = 0; i < size; i++)
  24. {
  25. if (arr[i]->Ulitsa == Ulitsa && Dom == Dom && Gorod == Gorod)
  26. cout << arr[i]->index << endl;
  27. }
  28. return 0;
  29. }
  30.  
  31. int main() {
  32. Adres* arr[23] = { new Adres(), new Adres(),new Adres() };
  33. arr[0]->Dom = 14;
  34. arr[0]->Ulitsa = "Festivalynaya";
  35. arr[0]->Gorod = "Kasimov";
  36. arr[0]->index = 110542;
  37. arr[1]->Dom= 88;
  38. arr[1]->Ulitsa = "Volokamskaya";
  39. arr[1]->Gorod = "Moskva";
  40. arr[1]->index = 606674;
  41. arr[2]->Dom = 18;
  42. arr[2]->Ulitsa = "Krasnaya";
  43. arr[2]->Gorod = "Novgorod";
  44. arr[2]->index = 391303;
  45. Index(arr, sizeof(arr) / sizeof(arr[0]),1);
  46. Adress(arr, sizeof(arr) / sizeof(arr[0]),14,"Festivalynaya","Kasimov");
  47. delete arr[0];
  48. delete arr[1];
  49. delete arr[2];
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement