Adrita

stucture ( oop lab 2) 3rd sem

Jan 13th, 2020
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. struct card
  4. {
  5. int suit;
  6. int number;
  7. };
  8. string getsuit(int x)
  9. {
  10. if(x==1)
  11. return "spades";
  12. else if(x==2)
  13. return "hearts";
  14. else if(x==3)
  15. return "clubs";
  16. else if(x==4)
  17. return "diamonds";
  18. }
  19. string getnumber(int y)
  20. {
  21. if(y==2)
  22. return "2";
  23. if(y==3)
  24. return "3";
  25. if(y==4)
  26. return "4";
  27. if(y==5)
  28. return "5";
  29. if(y==6)
  30. return "6";
  31. if(y==7)
  32. return "7";
  33. if(y==8)
  34. return "8";
  35. if(y==9)
  36. return "9";
  37. if(y==10)
  38. return "10";
  39. if(y==11)
  40. return "ace";
  41. if(y==12)
  42. return "king";
  43. if(y==13)
  44. return "queen";
  45. if(y==14)
  46. return "jack";
  47. }
  48. int main()
  49. {
  50. int n,i;
  51. struct card a;
  52. cin>>n;
  53. for(i=1; i<=n; i++)
  54. {
  55. cin>>a.suit>>a.number;
  56. cout<<"card "<<i<<" is of "<<getnumber(a.number)<<" of "<<getsuit(a.suit)<<"\n";
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment