Advertisement
huutho_96

Hướng dẫn giải đề CTDL GT học kì 2 năm 2014 - 2015 UIT

Jun 23rd, 2016
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. //cau 1
  7. // i = 4
  8. //50 17 15 9 62 86 12 14 32 6
  9. //50 17
  10. //50 17 15
  11. //50 17 15 9
  12. //62 50 17 15 9
  13. //86 62 50 17 15 9
  14. //86 62 50 17 15 12 9
  15. //86 62 50 17 15 14 12 9
  16. //86 62 50 32 17 15 14 12 9
  17. //86 62 50 32 17 15 14 12 9 6
  18.  
  19.  
  20. //cau 2
  21. //typedef struct item* ptr;
  22. //struct item{
  23. //  int info;
  24. //  ptr next;
  25. //};
  26. //
  27. //void ThapPhan(ptr Head)
  28. //{
  29. //  int i = 0;
  30. //  int sum = 0;
  31. //  ptr p = Head;
  32. //  while (p != NULL)
  33. //  {
  34. //      sum += p->info * pow(2.0, i);
  35. //      i++;
  36. //      p = p->next;
  37. //  }
  38. //
  39. //  cout << sum;
  40. //}
  41.  
  42.  
  43. //cau 32
  44. //struct Node
  45. //{
  46. //  Node* *pLeft, *pRight;
  47. //  int key;
  48. //};
  49. //typedef Node* TREE;
  50. //
  51. //int Height(TREE root)
  52. //{
  53. //  if (root == NULL) return 0;
  54. //  int a = Height((TREE)root->pLeft);
  55. //  int b = Height((TREE)root->pRight);
  56. //  if (a > b) return a;
  57. //  return b;
  58. //}
  59. //
  60. //void DuyetTheoMuc(TREE root, int k, int Muc = 0)
  61. //{
  62. //  if (root == NULL) return;
  63. //  DuyetTheoMuc((TREE)root->pLeft, k, Muc + 1);
  64. //
  65. //  if (Muc == k)
  66. //      cout << root->key << "\t";
  67. //
  68. //  DuyetTheoMuc((TREE)root->pRight, k, Muc + 1);
  69. //}
  70. //
  71. //void main()
  72. //{
  73. //  TREE root;
  74. //  DuyetTheoMuc(root, 5);
  75. //}
  76.  
  77.  
  78. //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement