-
Notifications
You must be signed in to change notification settings - Fork 3
/
偏序关系求极大极小元.cpp
51 lines (47 loc) · 914 Bytes
/
偏序关系求极大极小元.cpp
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
bool min[50],max[50],alphabet[50];
int judge(char c)
{
if (c >= 'a' && c <= 'z')
return 1;
return 0;
}
void output(bool which[])
{
int count = 0;
while (!alphabet[count] || !which[count])
count++;
printf("%c", count + 'a');
for (count++; count < 26; count++)
if (alphabet[count] && which[count])
printf(",%c", count + 'a');
printf("\n");
}
int main()
{
char c;
memset(alphabet, false, sizeof(alphabet));
memset(max, true, sizeof(max));
memset(min, true, sizeof(min));
while ((c = getchar()) != '\n')
if (judge(c))
alphabet[c - 'a'] = true;
c = getchar();
while (c != '\n')
{
while (!(judge(c)))
c = getchar();
max[c - 'a'] = false;
c = getchar();
while (!(judge(c)))
c = getchar();
min[c - 'a'] = false;
c = getchar();
while (c != '\n' && (!judge(c)))
c = getchar();
}
output(min);
output(max);
}