Research portable Memory game | Исследовать портируемую игру Память
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.2KB

  1. #include <stdio.h>
  2. #include "utlist.h"
  3. typedef struct el {
  4. int id;
  5. struct el *next, *prev;
  6. } el;
  7. int main()
  8. {
  9. int i;
  10. el els[10], *e;
  11. el *headA = NULL;
  12. el *headB = NULL;
  13. for(i=0; i<10; i++) {
  14. els[i].id=(int)'a'+i;
  15. }
  16. /* test DL macros */
  17. printf("DL macros\n");
  18. DL_APPEND(headA,&els[0]);
  19. DL_APPEND(headA,&els[1]);
  20. DL_APPEND(headA,&els[2]);
  21. DL_FOREACH(headA,e) {
  22. printf("%c ", e->id);
  23. }
  24. printf("\n");
  25. DL_APPEND(headB,&els[3]);
  26. DL_APPEND(headB,&els[4]);
  27. DL_APPEND(headB,&els[5]);
  28. DL_FOREACH(headB,e) {
  29. printf("%c ", e->id);
  30. }
  31. printf("\n");
  32. DL_CONCAT(headA,headB);
  33. DL_FOREACH(headA,e) {
  34. printf("%c ", e->id);
  35. }
  36. printf("\n");
  37. /* other variations */
  38. headA = NULL;
  39. DL_CONCAT(headA,headB);
  40. DL_FOREACH(headA,e) {
  41. printf("%c ", e->id);
  42. }
  43. printf("\n");
  44. headB = NULL;
  45. DL_CONCAT(headA,headB);
  46. DL_FOREACH(headA,e) {
  47. printf("%c ", e->id);
  48. }
  49. printf("\n");
  50. headA=NULL;
  51. headB=NULL;
  52. DL_APPEND(headA,&els[0]);
  53. DL_APPEND(headB,&els[1]);
  54. DL_CONCAT(headA,headB);
  55. DL_FOREACH(headA,e) {
  56. printf("%c ", e->id);
  57. }
  58. printf("\n");
  59. return 0;
  60. }