Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- ////////////////////////////////////////
- struct T
- {
- float fBallance;
- int nNumber;
- float mult();
- };
- void foo(T *p);
- /////////////////////////////////////////////////////////////////////
- int main() //
- {
- T t[99];
- t[1].fBallance = 412.23;
- t[1].nNumber = 1;
- t[2].fBallance = 1023.23;
- t[2].nNumber = 1;
- printf("mult = %f\n", t[2].mult());
- // foo(&t[1]);
- foo(t+1);
- }
- /////////////////////////////////////////////////////////////////
- void foo(T *p)
- {
- printf("p->fBallance = %.2f\n", (*p).fBallance);
- printf("p->fBallance = %.2f\n", p->fBallance);
- float *fp = (float*)p;
- //printf("qqqq = %.2f\n", (float)*fp);
- printf("qqqq = %.2f\n", (float)fp[0]);
- int *pi = (int*)p;
- printf("int = %d\n", pi[1]);
- }
- float T::mult()
- {
- return fBallance * 2;
- }
- /*
- #include <stdio.h>
- ////////////////////////////////////////
- struct T
- {
- float fBallance;
- int nNumber;
- };
- void foo(T *p);
- /////////////////////////////////////////////////////////////////////
- int main() //
- {
- T t[99];
- t[1].fBallance = 1012.23;
- t[1].nNumber = 1;
- // foo(&t[1]);
- foo(t+1);
- }
- /////////////////////////////////////////////////////////////////
- void foo(T *p)
- {
- printf("p->fBallance = %.2f\n", (*p).fBallance);
- printf("p->fBallance = %.2f\n", p->fBallance);
- float *fp = (float*)p;
- //printf("qqqq = %.2f\n", (float)*fp);
- printf("qqqq = %.2f\n", (float)fp[0]);
- int *pi = (int*)p;
- printf("int = %d\n", pi[1]);
- }
- */
- /*
- #include <stdio.h>
- int _foo(char *psz);
- /////////////////////////////////////////////////////////////////////
- int main() //
- {
- char sz[99];
- scanf("%s", sz);
- _foo(sz);
- return 0;
- }
- ////////////////////////////////////////////////////////////////////
- int _foo(char *psz) //
- {
- char a1 = psz[0]%2,
- b1 = psz[1]%2,
- c1 = psz[2]%2,
- d1 = psz[3]%2;
- if((a1 == 1 and b1 == 1) or (a1 == 0 and b1 == 0 )) printf("B");
- if((a1 == 1 and b1 == 0) or (a1 == 0 and b1 == 1 )) printf("W");
- if((c1 == 1 and d1 == 1) or (c1 == 0 and d1 == 0 )) printf("B");
- if((c1 == 0 and d1 == 1) or (c1 == 1 and d1 == 0 )) printf("W");
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement