-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bffd2a
commit 76e5be2
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include <ctype.h> | ||
#include <stdint.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
struct Stack { | ||
char character; | ||
struct Stack *next; | ||
}; | ||
|
||
typedef struct Stack stack; | ||
|
||
void push(stack **decrypted_string, char character) { | ||
stack *new_item = (stack *)malloc(sizeof(stack)); | ||
|
||
new_item->character = character; | ||
new_item->next = *decrypted_string; | ||
*decrypted_string = new_item; | ||
} | ||
|
||
char pop(stack **decrypted_string) { | ||
char character = (*decrypted_string)->character; | ||
stack *temp = *decrypted_string; | ||
|
||
*decrypted_string = (*decrypted_string)->next; | ||
free(temp); | ||
return character; | ||
} | ||
|
||
int main() { | ||
int16_t c; | ||
char character; | ||
stack *decrypted_string = NULL; | ||
|
||
scanf("%d", &c); // reads the number | ||
character = getchar(); // reads the newline | ||
|
||
character = getchar(); | ||
|
||
while (character != EOF) { | ||
if (character != '\n') { | ||
if (!isupper(character)) { | ||
push(&decrypted_string, character); | ||
} | ||
} else { | ||
while (decrypted_string != NULL) { | ||
putchar(pop(&decrypted_string)); | ||
} | ||
putchar('\n'); | ||
} | ||
character = getchar(); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
int main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
c |