Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "iostream"
- #include "stdio.h"
- #include "conio.h"
- #include "cstdlib"
- #include <fstream>
- using namespace std;
- #define mSize 3;
- int main()
- {
- setlocale (LC_ALL, "Russian");
- int n,i,a[100],max=0,l,b,r=0,s,s1;
- ofstream outfile ("array.txt");
- cout<<"Введите кол-во элементов: ";
- cin>>n;
- cout << "Запишите числа в файл\n";
- for(i=0; i<n; i++)
- {
- cin >> l;
- outfile << l << endl;
- }
- ifstream somefile ("array.txt");
- for(i=0; i<n; i++)
- {
- somefile >> s;
- if (max<s) {max=s; r=i;}
- }
- ifstream somefile1 ("array.txt");
- for(i=0; i<n; i++)
- {
- somefile1 >> s;
- if (i>=r)
- if (s!=0) {a[i-r]=s; cout<<a[i-r]<<" ";}
- }
- cout << endl;
- cout << max << endl<<r;
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement