Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //In fisierul numere.in se afla cel mult 5k numere reale. Scrieti un program care citeste nr. din fisier si afiseaza pe ecran numarul de ordine
- //al primei, respectiv ultimei linii pe care se afla cel mai mare numar din fisier.
- #include <fstream>
- #include <iostream>
- #include <climits>
- using namespace std;
- void main()
- {
- ifstream f("numere.in");
- ofstream g("date.out");
- float max,x;
- int p,u,i;
- f>>x;
- max=x;
- p=1;
- u=1;
- i=1;
- while (f>>x)
- {
- i++;
- if (x>max)
- {
- max=x;
- p=i;
- u=1;
- }
- else
- if (x==max)
- u=i;
- }
- g<<p<<" "<<u;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement