-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab6.c
61 lines (55 loc) · 1005 Bytes
/
lab6.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdio.h>
#include <stdbool.h>
unsigned int read_integer(void)
{
unsigned int n;
scanf("%u",&n);
return n;
}
void print_prime(void)
{
printf("prime\n");
}
void print_not_prime(void)
{
printf("not prime\n");
}
int main(void)
{
unsigned int i;
unsigned int n=read_integer();
bool is_prime;
main_loop:
if (n==0)
goto done_main;
if (n!=1)
goto not_1;
print_not_prime();
goto done_1;
not_1:
is_prime=true;
i=2;
loop:
if (i*i>n)
goto break_loop;
if ((n%i)!=0)
goto not_div;
is_prime=false;
goto break_loop;
not_div:
i++;
goto loop;
break_loop:
if (!is_prime)
goto not_prime;
print_prime();
goto done_prime;
not_prime:
print_not_prime();
done_prime:
done_1:
n=read_integer();
goto main_loop;
done_main:
return 0;
}