Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Sa se afiseze cate muchii au costul maxim si care sunt aceste muchii.
- #include<iostream>
- using namespace std;
- int a[10][10], i, j, n, k, m, c, v[50], t, x, b[50];
- void citire ()
- {
- cout<<"Nr de varfuri: "; cin>>n;
- cout<<"Nr de muchii: "; cin>>m;
- for(k=1; k<=m; k++)
- {
- cout<<"Varful 1 al muchiei "<<k<<" : ";cin>>i;
- cout<<"Varful 2 al muchiei "<<k<<" : ";cin>>j;
- cout<<"Costul muchiei "<<k<<" : "; cin>>c;
- t++;
- v[t]=c;
- }
- }
- void cost_maxim ()
- {
- int maxi=v[1], nr=0;
- for(t=1; t<=m; t++)
- if(maxi<v[t])
- maxi=v[t];
- for(t=1; t<=m; t++)
- if(v[t]==maxi)
- {
- nr++;
- x++;
- b[x]=t;
- }
- cout<<"* "<<nr<<" muchii au costul maxim ("<<maxi<<")"<<'\n';
- cout<<"* "<<"Muchiile care au costul maxim sunt:"<<'\n';
- for(x=1; x<=nr; x++)
- cout<<"** "<<b[x]<<'\n';
- }
- int main ()
- {
- citire();
- cost_maxim();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement