U E D R , A S I H C RSS

빵페이지/소수출력

  • 례대 만들.
    2, 3, 5, 7, * * *

~cpp 
#include <iostream>
using namespace std;

int main()
{
        int a;
        cout << ". : ";
        cin >> a;

        for(int i=2;i<=a;i++)
        {
                int count = 0;
                for(int j=2;j<i;j++)
                {
                        if((i%j)!=0)
                           count++;
                }
				
	       if(count==(i-2))
                    cout << i << " ";
        }
        cout << endl;
return 0;
}

보람^^;
  • 런 방 ㅎㅎ ~ - 민
  • ~ 벌.. 대~ 내 . for문 는데ㅡ -

~cpp 
#include<iostream>
using namespace std;
int main()
{	
	int num;
	cout<<":";
	cin>>num;
for(int k=2;k<num;k++)
{
	int count=0;
	for(int i=1;i<=num;i++)
	{	
		for(int j=2;j<=num;j++)
		{
				if(j*i==k)
				count++;
		}
	}
	if(count==1)
		cout<<k<<" ";
}
 return 0;
} 
// ..( ;)른 방 .ㅡ
* 런방 .. ~^^ -

~cpp 
#include <iostream.h>
void main()
{
	int num;
	int count;
	cout << " = ";
	cin >> num;
	if (num >= 2)
		cout << "2\n";
	else 
		cout << " 대략 !\n";

	for (int i = 2; i <= num; i++)
	{	
		for (int j = 2; j < i; j++)
		{
			if (i % j == 0)
				count++;
		}
		if (count == 0)
			cout << i << "\n";
		count = 0;
	}
}


늦는...
-_-;;;;;;;;;
  • ~ ~ -

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:38
Processing time 0.0091 sec