Няшная / Говнокод #4088 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
#include <stdio.h>

#define template_pair_declare(x,y) \
struct x##_##y##_pair \
{ \
    x first; \
    x second; \
}

#define template_pair(x,y) struct x##_##y##_pair

#define template_mkpair_declare(x,y) \
template_pair(x,y) mkpair_##x##_##y(x _first,y _second) \
{ \
    template_pair(x,y) res;res.first=_first;res.second=_second; \
    return res; \
}

#define template_mkpair(x,y) mkpair_##x##_##y

template_pair_declare(int,int);
template_pair_declare(float,float);

int main()
{
    template_pair(int,int) ip;
    scanf("%d%d",&ip.first,&ip.second);
    printf("Sum: %d\n",ip.first+ip.second);
    template_pair(float,float) fp;
    scanf("%f%f",&fp.first,&fp.second);
    printf("Sum: %f\n",fp.first+fp.second);
    return 0;
}

Шаблонные структуры и шаблонные функции для труЪ сишников.

Запостил: frp frp, (Updated )

Комментарии (9) RSS

Добавить комментарий

Семь раз отмерь — один отрежь, guest!

    А не использовать ли нам bbcode?


    8