Advertisement
punidota

Untitled

Sep 6th, 2015
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1.  
  2. #include "stdafx.h"
  3. #include "iostream"
  4. #include "conio.h"
  5. using namespace std;
  6.  
  7. int StringToInt(const char * str)
  8. {
  9.     char * pLastChar = NULL;
  10.     int param = strtol(str, &pLastChar, 10);
  11.     return param;
  12. }
  13.  
  14. int main(int argc, char*argv[])
  15. {
  16.     char symbol = *argv[2];
  17.     if (symbol == '+')
  18.         cout << "a1 + b1 = " << StringToInt(argv[1]) + StringToInt(argv[3]);
  19.     else
  20.     if (symbol == '-')
  21.         cout << "a1 - b1 = " << StringToInt(argv[1]) - StringToInt(argv[3]);
  22.     else
  23.     if (symbol == '*')
  24.         cout << "a1 * b1 = " << StringToInt(argv[1]) * StringToInt(argv[3]);
  25.     else
  26.         cout << "a1 / b1 = " << StringToInt(argv[1]) / StringToInt(argv[3]);
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement