Advertisement
Guest User

Untitled

a guest
May 24th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include "iostream"
  2. #include "stdio.h"
  3. #include "conio.h"
  4. #include "cstdlib"
  5. #include <fstream>
  6.  
  7. using namespace std;
  8. #define mSize 3;
  9. int main()
  10. {
  11. setlocale (LC_ALL, "Russian");
  12. int n,i,a[100],max=0,l,b,r=0,s,s1;
  13. ofstream outfile ("array.txt");
  14. cout<<"Введите кол-во элементов: ";
  15. cin>>n;
  16. cout << "Запишите числа в файл\n";
  17. for(i=0; i<n; i++)
  18. {
  19. cin >> l;
  20. outfile << l << endl;
  21. }
  22.  
  23. ifstream somefile ("array.txt");
  24.  
  25.  
  26. for(i=0; i<n; i++)
  27. {
  28. somefile >> s;
  29. if (max<s) {max=s; r=i;}
  30. }
  31. ifstream somefile1 ("array.txt");
  32. for(i=0; i<n; i++)
  33. {
  34. somefile1 >> s;
  35. if (i>=r)
  36. if (s!=0) {a[i-r]=s; cout<<a[i-r]<<" ";}
  37. }
  38. cout << endl;
  39. cout << max << endl<<r;
  40. _getch();
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement