Guest User

Untitled

a guest
Nov 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. FILE *in;
  7. char stack[100];
  8. char str[100];
  9. int n;
  10. int c;
  11. int top;
  12. int bottom;
  13. int i;
  14.  
  15. if (argc != 2) {
  16. fprintf(stderr, "usage: %s file\n", argv[0]);
  17. exit(1);
  18. }
  19.  
  20. if ((in = fopen(argv[1], "r")) == NULL) {
  21. fprintf(stderr, "cannot open %s\n", argv[1]);
  22. exit(1);
  23. }
  24.  
  25. n = 0; top = 0; i = 0;
  26. while ((c = fgetc(in)) != EOF) {
  27. if (c >= '0' && c <= '9') {
  28. n = n * 10 + c - '0';
  29. continue;
  30. }
  31. if (c >= 'A' && c <= 'Z') {
  32. if (n != 0) {
  33. stack[top ++] = n;
  34. }
  35. str[i ++] = c;
  36. continue;
  37. }
  38. if (c == '(') {
  39. stack[top ++] = n;
  40. continue;
  41. }
  42. if (c == ')') {
  43. }
  44. if (c == '\n') {
  45. top = 0;
  46. n = 0;
  47. continue;
  48. }
  49. }
  50. }
Add Comment
Please, Sign In to add comment