Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream f("date.in");
- ofstream g("date.out");
- struct produs{
- char producator[501],tip[501];
- int anfab,pret,stoc;
- }v[1001];
- int n;
- bool cmp(const produs &a, const produs &b){
- if(strcmp(a.tip , b.tip) != 0){
- if(strcmp(a.tip , b.tip) > 0)
- return 1;
- }else{
- return a.pret < b.pret;
- }
- }
- void citire(){
- int i;
- f >> n;
- for(i = 1 ; i <= n ; i++)
- f >> v[i].producator >> v[i].tip >> v[i].anfab >> v[i].pret >> v[i].stoc;
- }
- void afiare_produse(){
- int i;
- for(i = 1 ; i <= n ; i++)
- g << v[i].producator << " " << v[i].tip << " " << v[i].anfab << " " << v[i].pret << " " << v[i].stoc << "\n";
- }
- void afiare_dupa_producator(char s[]){
- int i;
- for(i = 1 ; i <= n ; i++)
- if(!strcmp(s , v[i].producator))
- g << v[i].producator << " " << v[i].tip << " " << v[i].anfab << " " << v[i].pret << " " << v[i].stoc << "\n";
- }
- void sortare(){
- sort(v + 1 , v + n + 1 , cmp);
- }
- int main()
- {
- citire();
- sortare();
- afiare_produse();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement