Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Cate muchii au costul sunt mai mare decate costul mediu
- #include <iostream>
- #include <fstream>
- using namespace std;
- int n, a[10][10] ,i ,j ,k, m, c, nr, v[50], t, ma;
- void citire ()
- {
- ifstream f("citire.in");
- f>>n;
- f>>m;
- for(k=1;k<=m;k++)
- {
- f>>i;
- f>>j;
- f>>c;
- t++;
- v[t]=c;
- }
- f.close();
- }
- void numar()
- {
- int s=0;
- for(t=1; t<=m; t++)
- s=s+v[t];
- ma=s/m;
- for(t=1; t<=m; t++)
- if(v[t]>ma) nr++;
- cout<<'\n';
- cout<<nr<<" muchii au costul mai mare decat costul mediu. ("<<ma<<")";
- }
- int main ()
- {
- citire();
- numar();
- return 0;
- }
- /* citire.in */
- 5
- 7
- 1
- 2
- 1
- 1
- 3
- 2
- 1
- 4
- 3
- 2
- 3
- 4
- 2
- 5
- 5
- 4
- 3
- 6
- 3
- 5
- 7
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement