SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. struct spectacol{
  4.  float in,sf,r;};
  5.  spectacol A[10],a;
  6.  int main()
  7.  { int n,i,O,P=0,j,S[10];
  8.    cout<<"Nr de spectacole=";
  9.    cin>>n;
  10.    cout<<"Nr de ore=";
  11.    cin>>O;
  12.    for(i=1;i<=n;i++)
  13.     {cout<<"spectacolul "<<i<<" incepe la ora ";
  14.      cin>>A[i].in;
  15.      cout<<"spectacolul "<<i<<" se sfarseste la ora ";
  16.      cin>>A[i].sf;}
  17.      cout<<endl;
  18.    for(i=1;i<=n;i++)
  19.        A[i].r=A[i].sf-A[i].in;
  20.    for(i=1;i<=n;i++)
  21.      for(j=1;j<=n;j++)
  22.         if(A[i].in<A[j].in)
  23.           {a=A[j];
  24.            A[j]=A[i];
  25.            A[i]=a;}
  26.    i=1;
  27.    j=1;
  28.     while(O!=0 && i<=n)
  29.       { if(A[i].r<=O)
  30.           {P=P+A[i].r;
  31.            O=O-A[i].r;
  32.            cout<<"Spectacol "<<j<<" incepe la ora "<<A[i].in;
  33.            cout<<endl<<" Spectacol "<<j<<" se termina la ora "<<A[i].sf<<endl;
  34.            j++;}
  35.          i++;
  36.      }
  37.    cout<<endl<<"nr de ore de spectacol="<<P<<endl;
  38.  
  39.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top