Advertisement
Guest User

2

a guest
Apr 25th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <stdio.h>
  3. #include <conio.h>
  4. #include <iostream>
  5. #define SIZE 10 // размерность строки
  6. using namespace std;
  7. struct Man {
  8. char name[SIZE]; // фамилие и инициалы
  9. int vozrast;
  10. float doxod;
  11. };
  12. //-----------------------------------—
  13. Man Init_st(int i)//вводится элементы структурa
  14. {
  15. Man x;
  16. cout << i << " - ый человек " << endl;
  17. cout << "ФИО: ";
  18. cin >> x.name;
  19. cout << "Возраст: ";
  20. cin >> x.vozrast;
  21. cout << "Доход: ";
  22. cin >> x.doxod;
  23. return x;
  24. }
  25. //-----------------------------------—
  26. void Sort_el(int m, Man *x)//сортировка масс. подоходам
  27. {
  28. Man y; int k = 1, i = 0;
  29. while (i<m && k == 1) {
  30. k = 0;
  31. for (int j = 0; j<m - 1; j++) {
  32. if (x[j].doxod>x[j + 1].doxod)
  33. {
  34. y = x[j]; x[j] = x[j + 1]; x[j + 1] = y;
  35. k = 1;
  36. }
  37. }
  38. }
  39. }
  40. //----------------------------------—
  41. int Show_st(int m, Man *x) {
  42. for (int i = 0; i<m; i++)
  43. {
  44. cout << "------------------" << endl;
  45. cout << "Фамилия возраст доход" << endl;
  46. printf("\n % 10s % 3d %7.3f ",
  47. x[i].name, x[i].vozrast, x[i].doxod);
  48. }
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement