Advertisement
Guest User

Mirko

a guest
Mar 17th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int wiekszy(int arg1, int arg2)
  7. {
  8. if (arg1>arg2) return 1;
  9. else if (arg2>arg1) return 2;
  10. else return 0;
  11. }
  12. int wiekszy(float arg1, float arg2)
  13. {
  14. if (arg1 > arg2 && (arg1 - arg2)>0.0001) return 1;
  15. else if (arg2>arg1 && (arg2 - arg1)>0.0001) return 2;
  16. else return 0;
  17. }
  18. int wiekszy(char arg1[], char arg2[])
  19. {
  20. if (strcmp(arg1, arg2) < 0) return 2;
  21. else if (strcmp(arg1, arg2) > 0) return 1;
  22. else return 0;
  23. }
  24. int main()
  25. {
  26. int a, b;
  27. float c, d;
  28. char e[1], f[1];
  29. char *wsk1 = e;
  30. char *wsk2 = f;
  31. int w;
  32.  
  33. cout << "Podaj Wybor" << endl;
  34. cout << "1.calkowite" << endl;
  35. cout << "2.rzeczywiste" << endl;
  36. cout << "3.lancuchy znakow" << endl;
  37. cin >> w;
  38. switch (w)
  39. {
  40. case 1:
  41. {
  42. cin >> a;
  43. cin >> b;
  44. cout << wiekszy(a, b);
  45. break;
  46. }
  47. case 2:
  48. {
  49. cin >> c;
  50. cin >> d;
  51. cout << wiekszy(c, d);
  52. break;
  53. }
  54. case 3:
  55. {
  56. cin >> e;
  57. cin >> f;
  58. cout << wiekszy(e, f);
  59. break;
  60. }
  61. default:
  62. cout << "zle dane";
  63. }
  64. delete[]wsk1; //Jak zakomentuje te dwa delete to program działa ale wywala później
  65. delete[]wsk2; //
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement