Advertisement
Pafnytiu

структуры 2 -11

Dec 23rd, 2015
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include <string>
  2. using namespace std;
  3. ifstream in("input.txt");
  4. ofstream out("output.txt");
  5. struct bibl
  6. {
  7. int stoimost,kol;
  8. string vid,sort;
  9. void show();
  10. void print();
  11. };
  12. void bibl::show()
  13. {
  14. cout << setw(8) << vid << setw (10) << stoimost <<setw (8) << sort <<setw(8)<< kol << endl;
  15. }
  16. void bibl::print()
  17. {
  18. out << setw (8) << vid << setw (10) << stoimost << setw (8) << sort << setw (8) << kol << endl;
  19. }
  20.  
  21. int main()
  22. {
  23. setlocale(LC_ALL, "rus");
  24. bibl book[10];
  25. int num;
  26. int i,j,n=0;
  27. if(!in)
  28. cout << "Oшибка при открытии файла input.txt\n";
  29. else
  30. {
  31. while(in.peek()!=EOF)
  32. {
  33. in >> book[n].vid;
  34. in >> book[n].stoimost;
  35. in >> book[n].sort;
  36. in >> book[n].kol;
  37.  
  38. book[n].show();
  39. n++;
  40. }
  41. cout <<"Заданая величина: ";
  42. cin >> num ;
  43. if(!out) cout<< "Oшибка при открытии файла output.txt\n";
  44. else
  45. {
  46. j=0;
  47. for(i=0;i<n && !j;i++)
  48. if(book[i].kol >= num)
  49.  
  50. { for(j=i;j<n-1 ;j++)
  51. book[j]=book[j+1];
  52. n--;
  53. }
  54. for(i=0;i<n;i++)
  55. book[i].print();
  56. }
  57. }
  58.  
  59. in.close();out.close();
  60. system("pause");
  61. return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement