Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. int main()
  2. {
  3. int size_a, size_b;
  4. double a = 0, b = 0;
  5. int intresult = 0;
  6. double dubresult = 0;
  7. char operation;
  8. char in_type[15];
  9. int current = 0;
  10. int status;
  11. char * la;
  12. char * lb;
  13.  
  14. printf("\nWrite the type of input data ");
  15. scanf("%6s", in_type);
  16.  
  17. //
  18. if (!strcmp(in_type, "string"))
  19. {
  20. current = -1;
  21. printf("Enter max size of line a ");
  22. scanf("%d", &size_a);
  23.  
  24. la = new char[size_a];
  25. printf("Enter line a = ");
  26. scanf("%s", la);
  27.  
  28. printf("\nEnter the operation ");
  29. fflush(stdin);
  30. operation = getchar();
  31.  
  32. printf("Enter max size of line b ");
  33. scanf("%d", &size_b);
  34.  
  35. lb = new char[size_b];
  36. printf("\nEnter line b = ");
  37. scanf("%s", lb);
  38.  
  39. check_string_operation(in_type,operation, la, lb, size_a, size_b);
  40. getch();
  41. return 0;
  42. }
  43. else
  44. {
  45. printf("Enter a = ");
  46. status = scanf("%lf", &a);
  47.  
  48. printf("\nEnter the operation ");
  49. fflush(stdin);
  50. operation = getchar();
  51. //if (operation == 10)
  52. // operation = getchar();
  53.  
  54. //
  55. printf("\nEnter b = ");
  56. scanf("%lf", &b);
  57. }
  58.  
  59. switch (operation)
  60. {
  61. case '+':
  62. {
  63. current = 0;
  64. check_casual_operation(in_type, current, dubresult, intresult, a, b);
  65. break;
  66. }
  67. case '*':
  68. {
  69. current = 1;
  70. check_casual_operation(in_type, current, dubresult, intresult, a, b);
  71. break;
  72. }
  73. case '-':
  74. {
  75. current = 2;
  76. check_casual_operation(in_type, current, dubresult, intresult, a, b);
  77. break;
  78. }
  79. case '/':
  80. {
  81. current = 3;
  82. check_div_operation(in_type, current, dubresult, intresult, a, b);
  83. break;
  84. }
  85.  
  86. }
  87.  
  88. getch();
  89. return 0;
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement