Advertisement
alexon5519

14-programare

Jan 15th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3.  
  4. using namespace std;
  5.  
  6. struct produs{
  7. char denumire[20];
  8. int pret,cantitate,cod;
  9. };
  10. produs v[20],aux;
  11. int n,i,j,s=0;
  12. int main(){
  13. ifstream f1("atestat.in");
  14. ofstream f2("atestat.out");
  15. f1>>n;
  16. for(i=1;i<=n;i++){
  17. f1>>v[i].cod>>v[i].pret>>v[i].cantitate;
  18. f1.get();
  19. f1.get(v[i].denumire,20);
  20. f1.get();
  21. if(v[i].cantitate > 10)
  22. f2<<v[i].denumire<<", ";
  23. s=s+v[i].cantitate;
  24. }
  25. f2<<endl;
  26. for(i=1;i<n;i++)
  27. for(j=i+1;j<=n;j++){
  28. if(v[i].pret < v[j].pret){
  29. aux=v[i];
  30. v[i]=v[j];
  31. v[j]=aux;
  32. }
  33. }
  34. for(i=1;i<=n;i++)
  35. f2<<v[i].cod<<" "<<v[i].denumire<<" "<<v[i].pret<<" "<<v[i].cantitate<<endl;
  36. f2<<s;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement