You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
틀렸습니다
=>
답이 제대로 나오는거 같은데 자꾸 틀렸다고 나오서 원인을 모르겠어요,,ㅠㅠ
소스코드 첨부
#include
#include
using namespace std;
int main() {
int n,k=0,j=0,i=0;
unsigned long a[100000],b[100000];
bool prime[100001] = { false, }, check=false;
for (int i = 2; i*i<= 100000; i++) {
if (prime[i] == false) {
a[k++] = i;
for (j = i * i; j <= 100000; j += i)
prime[j] = true;
}
}
do{
check = false;
scanf("%d", &n);
if (n == 0) break;
for ( i = 0; i <= k/2; i++) {
for (int j = i; j < k; j++) {
if (n - a[i] == a[j])
{
if (check == true)
continue;
printf("%d = %d + %d\n", n, a[i], a[j]);
//cout << n << " = " << a[i] << "+ " << a[j] << endl;
check = true;
break;
}
}
}
if(check==false)
cout << "Goldbach's conjecture is wrong.\n";
}while(n!=0);
}
The text was updated successfully, but these errors were encountered:
C++,
C++17
에러 결과
틀렸습니다
=>
답이 제대로 나오는거 같은데 자꾸 틀렸다고 나오서 원인을 모르겠어요,,ㅠㅠ
소스코드 첨부
#include
#include
using namespace std;
int main() {
int n,k=0,j=0,i=0;
unsigned long a[100000],b[100000];
bool prime[100001] = { false, }, check=false;
}
The text was updated successfully, but these errors were encountered: