arrow_forward همه ارسال‌ها

جزئیات ارسال کد#589

code_blocks
مسئله مربوطه: عدد اول (#33) arrow_outward
verified
وضعیت داوری نهایی: پذیرفته شد
terminal
زبان برنامه‌نویسی: C++
schedule
ارسال‌کننده و زمان:
shana (۲ سال پیش)
descriptionsolution.cpp ۳۸ خط • ۵۳۰ بایت
1#include <iostream>
2using namespace std;
3int main()
4{
5 int n; cin >> n;
6 int x = 2;
7 while ( x < n/2 )
8 {
9 if ( n % x == 0 )
10 {
11 cout << "Composite";
12 break;
13 }
14
15 else if ( n % x != 0 )
16 {
17 x ++;
18 }
19 }
20
21 if ( n == 1 )
22 {
23 cout << "Nothing";
24 }
25
26 else if ( n == 2 )
27 {
28 cout << "Prime";
29 }
30
31 else if ( x >= n/2 )
32 {
33 cout << "Prime";
34 }
35
36
37 return 0;
38}
کد ارسال‌شده برای داوری خودکار هاتکدز UTF-8