Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- using namespace std;
- ifstream in("input.txt");
- ofstream out("output.txt");
- struct bibl
- {
- int stoimost,kol;
- string vid,sort;
- void show();
- void print();
- };
- void bibl::show()
- {
- cout << setw(8) << vid << setw (10) << stoimost <<setw (8) << sort <<setw(8)<< kol << endl;
- }
- void bibl::print()
- {
- out << setw (8) << vid << setw (10) << stoimost << setw (8) << sort << setw (8) << kol << endl;
- }
- int main()
- {
- setlocale(LC_ALL, "rus");
- bibl book[10];
- int num;
- int i,j,n=0;
- if(!in)
- cout << "Oшибка при открытии файла input.txt\n";
- else
- {
- while(in.peek()!=EOF)
- {
- in >> book[n].vid;
- in >> book[n].stoimost;
- in >> book[n].sort;
- in >> book[n].kol;
- book[n].show();
- n++;
- }
- cout <<"Заданая величина: ";
- cin >> num ;
- if(!out) cout<< "Oшибка при открытии файла output.txt\n";
- else
- {
- j=0;
- for(i=0;i<n && !j;i++)
- if(book[i].kol >= num)
- { for(j=i;j<n-1 ;j++)
- book[j]=book[j+1];
- n--;
- }
- for(i=0;i<n;i++)
- book[i].print();
- }
- }
- in.close();out.close();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement