기본 콘텐츠로 건너뛰기

11월, 2017의 게시물 표시

C++ A8 with C++ standardArray

#include <iostream> #include <cstddef> #include <array> using namespace std; //@Writer 5396952 Hyeonmin LEE int main(){  const size_t arrSize = 1000;  array <bool, arrSize> arr;  int count = 0;  /*  c++ standard library array template  array <dataType, size> name;  size_t = unsigned int, good data type to represent array subscription  included in std namespace and is in header <cstddef>  */  for(size_t i = 0; i < 1000; i++)  {   arr[i] = true;  }  for(size_t i = 2; i < 1000; i++)  {   if (arr[i] == true)   {    for(size_t j = i + 1; j < 1000; j++)    {//loop checks if there is a number devidable by 2, and by the numbers after     if(j % i == 0)     {      arr[j] = false;     }    }   }  }    for(int i = 2; i < 1000; i++)  {   if(arr[i] == true)   {    count++;    cout << count << ". " << i << " is prime number" << endl;   }  } return 0; } //뭘봐 눈깔아

C++ A8

#include <iostream> using namespace std; //@Writer 5396952 Hyeonmin LEE int main(){  bool arr[1000];  int count = 0;  for(int i = 0; i < 1000; i++)  {   arr[i] = true;  }  for(int i = 2; i < 1000; i++)  {   if (arr[i] == true)   {    for(int j = i + 1; j < 1000; j++)    {//loop checks if there is a number devidable by 2, and by the numbers after     if(j % i == 0)     {      arr[j] = false;     }    }   }  }    for(int i = 2; i < 1000; i++)  {   if(arr[i] == true)   {    count++;    cout << count << ". " << i << " is prime number" << endl;   }  } return 0; } /*I'm thinking to use it for my JAVA assignment if it's possible^^ got to know that JAVA doesn't have unsigned int.. java is weird */