Skip to content

Commit e9c2321

Browse files
committed
🎉
1 parent b7ea8d7 commit e9c2321

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

PF1-3/resit1-2023/problem4/prob4.c

+5-11
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@
77
#include <stdlib.h>
88
#include <string.h>
99

10-
void resetCounts (char *chars) {
11-
/* resets the histogram of characters */
12-
for (int i = 0; i < 26; i++) chars[i] = 0;
13-
}
14-
1510
int main(int argc, char *argv[]) {
16-
int wLen = 0, found = 0;
17-
char ch, word[200], chars[26] = {0};
11+
int found = 0;
12+
char ch, word[200];
1813

1914
// read each word and check for isogram
2015
while (scanf("%s", word) == 1) {
16+
int chars[26] = {0}; // histogram for characters in word
17+
int wLen = 0;
2118
for (int i = 0; i < strlen(word); i++) {
2219
ch = word[i];
2320
if (ch == '.') {
@@ -33,12 +30,9 @@ int main(int argc, char *argv[]) {
3330
word[wLen++] = ch;
3431
}
3532
if (wLen) {
36-
printf(found ? " " : "");
37-
printf("%s", word);
33+
printf(found ? " %s" : "%s", word);
3834
found = 1;
3935
}
40-
resetCounts(chars);
41-
wLen = 0;
4236
}
4337
printf("\n");
4438
return 0;

0 commit comments

Comments
 (0)