Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct
- {
- char name[10];
- int vip;
- int vuz;
- float pr;
- } school;
- void IndexSort(school arr[], int n, int *B)
- {
- int i,j,t = 0;
- for(i = 0; i < n; i++)
- {
- B[i] = i;
- }
- for (i = n-2; i>=0; --i)
- {
- for (j = n-1; j>0; --j)
- {
- if (arr[i].pr < arr[j].pr)
- {
- t=B[i];
- B[i]=B[j];
- B[j]=t;
- }
- }
- }
- }
- int main()
- {
- int i, j, t, n;
- int B[n];
- school S;
- cout << "Input amount of schools: ";
- cin >> n;
- cout << endl;
- school* arr = new school[n];
- for (i = 0; i < n; i++)
- {
- cout << "Input school name: ";
- cin >> arr[i].name;
- cout << "Input amount of graduate school:";
- cin >> arr[i].vip;
- cout << "Input amount of already students:";
- cin >> arr[i].vuz;
- if (arr[i].vip < arr[i].vuz)
- {
- cout << "You did mistake, try again " << endl;
- break;
- }
- }
- for(i = 0; i < n; i++)
- {
- S.pr = ((float)S.vip/(float)S.vuz)*100;
- arr[i] = S;
- }
- IndexSort(arr, n, B);
- for (i = 0; i < n; i++)
- cout << arr[i].name << " " << arr[i].vip << " " << arr[i].vuz << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement