Guest User

Untitled

a guest
Jun 14th, 2013
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include<iomanip>
  3. #include <fstream>
  4. //#define A max 99
  5. //-------------------------------------------------------------
  6. using namespace std;
  7. const int VF = 99;
  8. const char CDfv[]="Duomenys.txt";
  9. const char CRfv[]="Rezultatai.txt";
  10. //-------------------------------------------------------------
  11. int main(){
  12.     int n, dbd, max, sum, A[VF];
  13.     ifstream fd(CDfv);
  14.     fd >> n;
  15.     ofstream fr (CRfv);
  16.     for (int i=0; i<n; i++){
  17.         fd >> A[i];
  18. }
  19.         max=A[0];
  20.         for (int i=1; i<n; i++){
  21.             if (A[i]>max)
  22.                 max=A[i];
  23.         }
  24.         for (int i=1; i<=max; i++){
  25.             sum=0;
  26.             for(int j=0; j<n; j++){
  27.                 if(A[j]%i==0)
  28.                     sum=sum+1;
  29.             }
  30.     if (sum==n)
  31.     dbd=i;
  32.       }
  33.     fd.close();
  34.     fr.close();
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment