-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumComp.cpp
More file actions
52 lines (46 loc) · 921 Bytes
/
NumComp.cpp
File metadata and controls
52 lines (46 loc) · 921 Bytes
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
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
#define M 1000
char s1[M], s2[M];
int a[M], b[M];
int len1, len2, i;
void BJ()
{
len1 = strlen(s1);
len2 = strlen(s2);
if (len1 > len2)
std::cout << "greater\n";
if (len1 < len2)
std::cout <<"less\n";
if (len1 == len2)
{
int cmp = strcmp(s1, s2);
if (cmp > 0) {
std::cout << "greater\n";
}
else if (cmp < 0) {
std::cout << "less\n";
}
else {
std::cout << "equal\n";
}
}
}
void string2char(std::string src, char* dest) {
memcpy(dest, src.c_str(), strlen(src.c_str()));
}
int main(int argc, char* argv[])
{
if (argc != 3)
{
std::cout << "invalid input!\n";
return 1;
}
strcpy(s1, argv[1]);
strcpy(s2, argv[2]);
BJ();
}