Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int a;
  4. int b;
  5. int e;
  6. int r;
  7. char c;
  8.  
  9. int main(){
  10. printf("vvedite 1 chislo\n");
  11. scanf("%d", &a);
  12. printf("vvedite operachiyu\n");
  13. scanf("%s", &c);
  14. printf("vvedite 2 chislo\n");
  15. scanf("%d", &b);
  16.  
  17.  
  18. if (c =='+')
  19. r = 1;
  20. else if (c =='-')
  21. r = 2;
  22. else if (c =='*')
  23. r = 3;
  24. else if (c =='/')
  25. r = 4;
  26.  
  27. switch (r){
  28. case 1 : summa(); break;
  29. case 2 : raznost(); break;
  30. case 3 : umnogenie(); break;
  31. case 4 : delenie(); break;
  32. }
  33. }
  34. void summa(){
  35. e = a+b;
  36. printf("otvet %d", e);
  37. }
  38. void raznost(){
  39. e = a-b;
  40. printf("otvet %d", e);
  41. }
  42. void umnogenie(){
  43. e = a*b;
  44. printf("otvet %d", e);
  45. }
  46. void delenie(){
  47. e = a/b;
  48. printf("otvet %d", e);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement