-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path768.cpp
More file actions
94 lines (93 loc) · 1.86 KB
/
768.cpp
File metadata and controls
94 lines (93 loc) · 1.86 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
// strlen() 函数从字符串的开头位置依次向后计数,直到遇见\0,然后返回计时器的值。最终统计的字符串长度不包括\0
int main(int argc, char const *argv[])
{
// string a, b;
// cin >> a >> b;
char a[100], b[100]; /*定义一个最大长度为199, 末尾是'\0'的字符数组来存储字符串*/
fgets(a, 100, stdin);
fgets(b, 100, stdin);
if (a[strlen(a) - 1] == '\n')
{
a[strlen(a) - 1] = 0;
} // 去掉末尾回车
if (b[strlen(b) - 1] == '\n')
{
b[strlen(b) - 1] = 0;
} // 将字符串全部小写
for (int i = 0; i < strlen(a); i++)
{
if (a[i] >= 'A' && a[i] <= 'Z')
{
a[i] = a[i] + 32;
}
}
for (int i = 0; i < strlen(b); i++)
{
if (b[i] >= 'A' && b[i] <= 'Z')
{
b[i] = b[i] + 32;
}
}
// strcmp (A,B) -- 字符串比较函数。 当 A字符串和 B字符串 一样时,函数返回 0。
int t = strcmp(a, b);
if (t == 0)
{
cout << "=";
}
else if (t < 0)
{
cout << "<";
}
else
{
cout << ">";
}
return 0;
}
/*int t = 0;
if (a.size() < b.size())
{
cout << "<";
return 0;
}
else if (a.size() > b.size())
{
cout << ">";
return 0;
}
int len = min(a.size(), b.size());
for (int i = 0; i < len; i++)
{
if (a[i] == b[i] || a[i] == b[i] + 32 || a[i] == b[i] - 32)
{
t = 0;
}
else if (a[i] < b[i] && a[i] != b[i] - 32)
{
t--;
continue;
}
else
{
t++;
continue;
}
}
if (t == 0)
{
cout << "=";
}
else if (t < 0)
{
cout << "<";
}
else
{
cout << ">";
}
return 0;
}*/