AreWe

dragan2 fix

Mar 9th, 2018
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. const short len = 4;
  6.  
  7. struct SRacer {
  8. string fname;
  9. string lname;
  10. float record;
  11. int yearOfRecord;
  12. };
  13.  
  14. void PrintNames(SRacer *array, short araylen, int stringlen) {
  15. cout << "Imena na sustezateli, imashti duljina " << stringlen << " simvola :" << endl;
  16. for (short i = 0; i < araylen; i++) {
  17. bool isPrintedAlready = false;
  18.  
  19. if (array[i].fname.length() == stringlen) {
  20. for (short j = 0; j < i; j++) {
  21. if (array[i].fname.compare(array[j].fname) == 0) {
  22. isPrintedAlready = true;
  23. break;
  24. }
  25. }
  26. if (!isPrintedAlready) cout << array[i].fname << " ";
  27. }
  28. }
  29. cout << endl;
  30. }
  31.  
  32. int main() {
  33.  
  34. SRacer Racer[len] = {
  35. { "Pesho", "Peshov", 50, 1996 },
  36. { "Pesho", "Ivanov", 56, 1995 },
  37. { "Ivan", "Ignatov", 58, 1998 },
  38. { "Angel", "Angelov", 53, 2000 }
  39. };
  40.  
  41. PrintNames(Racer, len, 5);
  42.  
  43. system("pause");
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment