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 LL macros */
  17. printf("LL macros\n");
  18. LL_APPEND(headA,&els[0]);
  19. LL_APPEND(headA,&els[1]);
  20. LL_APPEND(headA,&els[2]);
  21. LL_FOREACH(headA,e) {
  22. printf("%c ", e->id);
  23. }
  24. printf("\n");
  25. LL_APPEND(headB,&els[3]);
  26. LL_APPEND(headB,&els[4]);
  27. LL_APPEND(headB,&els[5]);
  28. LL_FOREACH(headB,e) {
  29. printf("%c ", e->id);
  30. }
  31. printf("\n");
  32. LL_CONCAT(headA,headB);
  33. LL_FOREACH(headA,e) {
  34. printf("%c ", e->id);
  35. }
  36. printf("\n");
  37. /* other variations */
  38. headA = NULL;
  39. LL_CONCAT(headA,headB);
  40. LL_FOREACH(headA,e) {
  41. printf("%c ", e->id);
  42. }
  43. printf("\n");
  44. headB = NULL;
  45. LL_CONCAT(headA,headB);
  46. LL_FOREACH(headA,e) {
  47. printf("%c ", e->id);
  48. }
  49. printf("\n");
  50. headA=NULL;
  51. headB=NULL;
  52. LL_APPEND(headA,&els[0]);
  53. LL_APPEND(headB,&els[1]);
  54. LL_CONCAT(headA,headB);
  55. LL_FOREACH(headA,e) {
  56. printf("%c ", e->id);
  57. }
  58. printf("\n");
  59. return 0;
  60. }