-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq1.1.cpp
More file actions
36 lines (32 loc) · 797 Bytes
/
q1.1.cpp
File metadata and controls
36 lines (32 loc) · 797 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
#include <assert.h>
#include <iostream>
#include <string.h>
using namespace std;
int main(int argc, char **argv) {
assert(argc > 1);
char *input_string = argv[1];
// int string_length = sizeof(input_string);
int string_length = strlen(input_string);
bool check[127] = {0};
char c;
bool repeating_flag = 0;
int index;
printf("string_length: %d\n", string_length);
for (int i = 0; i < string_length; i++) {
c = input_string[i];
index = (int)c;
cout << c << ' ' << index << '\n';
if (index == 32)
continue;
if (check[index] == 0)
check[index] = 1;
else {
repeating_flag = 1;
break;
}
}
if (repeating_flag)
cout << "\nrepeating character is" << char(index) << '\n';
else
cout << "\nno repeating character\n";
}