-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3.c
More file actions
54 lines (54 loc) · 1.33 KB
/
3.c
File metadata and controls
54 lines (54 loc) · 1.33 KB
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
/*
You are given a sorted sequence x0 x1 ... xn -1
(either in the increasing or in the decreasing order)Sequence of
positive numbers, ending with -1.
You can assume that there are atleast two numbers before the ending -1.
Note : -1 is not a part of input. It only signifies that input has ended.
You have to output “True” if there are 3 distinct
numbers in the Input sequance else “False”Kindly do not use arrays in the code.
*/
#include <stdio.h>
int check(p, q, r)
{
if ((p != q) && (q != r))
{
printf("True\n");
}
else
{
printf("False\n");
}
}
int main()
{
int new, p, q, r;
p = q = r = new = 0;
scanf("%d", &new);
while (new != -1)
{
r = q;
q = p;
p = new;
printf(" R1 %d %d %d\n", p, q, r);
check(p, q, r);
scanf("%d", &new);
if (new != -1)
{
r = q;
q = p;
p = new;
check(p, q, r);
printf(" R2 %d %d %d\n", p, q, r);
scanf("%d", &new);
if (new != -1)
{
r = q;
q = p;
p = new;
check(p, q, r);
printf(" R3 %d %d %d\n", p, q, r);
scanf("%d", &new);
}
}
}
}