finished lab

This commit is contained in:
Rushil Umaretiya 2024-02-05 02:54:13 -05:00
parent d9d4568e99
commit 39538d8cbb
No known key found for this signature in database
GPG Key ID: 4E8FAF9C926AF959
5 changed files with 48 additions and 4 deletions

View File

@ -1 +1 @@
tar heels
tar heelsbruh

View File

@ -1 +1,2 @@
#!/bin/bash
#!/bin/bash
awk '/^cd/' $HISTFILE | wc -l

View File

@ -1 +1,2 @@
#!/bin/bash
#!/bin/bash
diff <(./lower < test0.txt) test0-result.txt

BIN
3-truncator/truncator Executable file

Binary file not shown.

View File

@ -1,2 +1,44 @@
// PID: 9DigitPidNoSpacesOrDashes
// PID: 730677144
// I pledge the COMP 211 honor code.
#include <stdlib.h>
#include <stdio.h>
int main() {
int lines[100];
int total, chars, cur, c;
total = 0;
chars = 0;
cur = 0;
while ((c = getchar()) != EOF) {
chars++;
if (c == '\n') {
chars = 0;
cur++;
putchar(c);
} else if (chars > 50) {
if (total == 0 || lines[total-1] != cur) {
lines[total] = cur;
total++;
}
chars = 1;
putchar('\n');
putchar(c);
} else {
putchar(c);
}
}
printf("Total lines over 50 chars: %d\n", total);
printf("Offending lines: ");
for (int i = 0; i < total; i++) {
printf("%d, ", lines[i]);
}
printf("\n");
return 0;
}