sahchas

Untitled

Dec 29th, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <cmath>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. void erathos(int array[] , int len) {
  9.     int j;
  10.     for (int i = 2 ; i < len ; i++){
  11.         if (array[i]!=5){
  12.             array[i] = 1 ;
  13.             j = 2 * i;
  14.             while( j < len)
  15.             {
  16.                 array[j] = 5;
  17.                 j *= i;
  18.             }
  19.         }
  20.     }  
  21.     for (int i = 0 ; i < len ; i++) {
  22.         cout << array[i] << " " ;
  23.     }
  24.     cout << endl ;
  25. }
  26.  
  27. int main(){
  28.     cout << "hello\n" ;
  29.     int a = 0  ;
  30.     int arr[20];
  31.    
  32.     for (int i = 0 ; i < 20 ; i++) {
  33.         arr[i] = 0 ;
  34.     }
  35.     erathos(arr , 20 ) ;
  36.     cin >> a  ;
  37.  
  38.     cout << "asd";
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment