Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main(int argc, char *argv[])
- {
- FILE *in;
- char stack[100];
- char str[100];
- int n;
- int c;
- int top;
- int bottom;
- int i;
- if (argc != 2) {
- fprintf(stderr, "usage: %s file\n", argv[0]);
- exit(1);
- }
- if ((in = fopen(argv[1], "r")) == NULL) {
- fprintf(stderr, "cannot open %s\n", argv[1]);
- exit(1);
- }
- n = 0; top = 0; i = 0;
- while ((c = fgetc(in)) != EOF) {
- if (c >= '0' && c <= '9') {
- n = n * 10 + c - '0';
- continue;
- }
- if (c >= 'A' && c <= 'Z') {
- if (n != 0) {
- stack[top ++] = n;
- }
- str[i ++] = c;
- continue;
- }
- if (c == '(') {
- stack[top ++] = n;
- continue;
- }
- if (c == ')') {
- }
- if (c == '\n') {
- top = 0;
- n = 0;
- continue;
- }
- }
- }
Add Comment
Please, Sign In to add comment