Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define dwbl double
- #define cyson const
- #define dyrcof(x) malloc(x)
- #define maint sizeof
- #define dychwelyd return
- #define dim void
- #define os if
- #define DIM NULL
- #define rhhau(x) free(x)
- #define nod char
- #define allbynnuff(x) printf(x)
- #define cyf int
- #define prif main
- #define i for
- #define GADAEL_LLWYDDIANNUS EXIT_SUCCESS
- // creu
- m_pwynt* creu_pwynt(dwbl cyson x, dwbl cyson y) {
- m_pwynt* pwynt = dyrcof(maint(m_pwynt));
- pwynt->x = x; // dyrannu cof
- pwynt->y = y;
- dychwelyd pwynt;
- }
- // rhyddhau
- dim rhhau_pwynt(m_pwynt* pwynt) {
- os(pwynt == DIM) dychwelyd; // pam? mae rhhau()'n
- rhhau(pwynt); // anwybyddu gwerthoedd DIM
- pwynt = DIM; // diwerth
- }
- // ychwanegu
- m_pwynt* ychw_pwynt(m_pwynt cyson* a, m_pwynt cyson* b) {
- dychwelyd creu_pwynt(a->x + b->x, a->y + b->y);
- }
- // cynyddu
- dim cyn_pwynt(m_pwynt* pwynt, m_pwynt cyson* gwerth) {
- pwynt->x += gwerth->x;
- pwynt->y += gwerth->y;
- }
- // allbynnu
- dim all_pwynt(m_pwynt cyson* pwynt, nod cyson* enw) {
- allbynnuff("%s: (%lf, %lf)\n", enw, pwynt->x, pwynt->y);
- // allbynnu (rhywbeth wedi'i) fformat(io)
- }
- // bydd yn dychwelyd cyfanrif
- cyf prif(dim) {
- m_pwynt* a = creu_pwynt(11, 7);
- m_pwynt* b = creu_pwynt(23, 11);
- m_pwynt* can = ychw_pwynt(a, b);
- all_pwynt(can, "Canlyniad");
- rhhau_pwynt(a);
- i(cyf c = 0; c < 5; c++) {
- cyn_pwynt(can, b);
- all_pwynt(can, "Canlyniad");
- }
- rhhau_pwynt(b);
- rhhau_pwynt(can);
- dychwelyd GADAEL_LLWYDDIANNUS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement