Advertisement
dllbridge

Untitled

Sep 15th, 2024
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.84 KB | None | 0 0
  1.  
  2.  
  3. #include <stdio.h>
  4.  
  5.  
  6.  
  7.  
  8.  
  9. ////////////////////////////////////////
  10. struct T
  11. {
  12.      
  13.    float fBallance;
  14.    int   nNumber;      
  15.    
  16.    float mult();
  17.  
  18. };
  19.  
  20.  
  21.  
  22. void foo(T *p);
  23.  
  24. /////////////////////////////////////////////////////////////////////
  25. int main()                                                         //
  26. {
  27.    
  28.     T t[99];
  29.    
  30.    
  31.     t[1].fBallance = 412.23;
  32.     t[1].nNumber   = 1;
  33.  
  34.     t[2].fBallance = 1023.23;
  35.     t[2].nNumber   = 1;    
  36.    
  37.     printf("mult = %f\n", t[2].mult());
  38.    
  39.  // foo(&t[1]);
  40.     foo(t+1);    
  41. }
  42.  
  43. /////////////////////////////////////////////////////////////////
  44. void foo(T *p)
  45. {
  46.      
  47.      printf("p->fBallance = %.2f\n", (*p).fBallance);
  48.      printf("p->fBallance = %.2f\n",   p->fBallance);  
  49.  
  50.      float *fp = (float*)p;
  51.    //printf("qqqq = %.2f\n", (float)*fp);
  52.      printf("qqqq = %.2f\n", (float)fp[0]);  
  53.      
  54.      int *pi = (int*)p;
  55.      
  56.      
  57.      
  58.      printf("int = %d\n", pi[1]);  
  59. }
  60.  
  61.  
  62.  
  63.  
  64.    float T::mult()
  65.    {
  66.          
  67.       return  fBallance * 2;    
  68.    }  
  69.  
  70. /*
  71.  
  72. #include <stdio.h>
  73.  
  74.  
  75.  
  76.  
  77.  
  78. ////////////////////////////////////////
  79. struct T
  80. {
  81.        
  82.    float fBallance;
  83.    int   nNumber;      
  84.        
  85. };
  86.  
  87.  
  88.  
  89. void foo(T *p);
  90.  
  91. /////////////////////////////////////////////////////////////////////
  92. int main()                                                         //
  93. {
  94.    
  95.     T t[99];
  96.    
  97.    
  98.     t[1].fBallance = 1012.23;
  99.     t[1].nNumber   = 1;
  100.    
  101.  // foo(&t[1]);
  102.     foo(t+1);    
  103. }
  104.  
  105. /////////////////////////////////////////////////////////////////
  106. void foo(T *p)
  107. {
  108.      
  109.      printf("p->fBallance = %.2f\n", (*p).fBallance);
  110.      printf("p->fBallance = %.2f\n",   p->fBallance);  
  111.  
  112.      float *fp = (float*)p;
  113.    //printf("qqqq = %.2f\n", (float)*fp);
  114.      printf("qqqq = %.2f\n", (float)fp[0]);  
  115.      
  116.      int *pi = (int*)p;
  117.      
  118.      
  119.      
  120.      printf("int = %d\n", pi[1]);  
  121. }
  122.  
  123. */
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151. /*
  152. #include <stdio.h>
  153.  
  154.  
  155.  
  156.  
  157. int _foo(char *psz);
  158.  
  159. /////////////////////////////////////////////////////////////////////
  160. int main()                                                         //
  161. {
  162.    
  163.     char sz[99];
  164.  
  165.  
  166.     scanf("%s", sz);
  167.    
  168.    _foo(sz);
  169.  
  170. return 0;
  171. }
  172.  
  173.  
  174. ////////////////////////////////////////////////////////////////////
  175. int _foo(char *psz)                                               //
  176. {
  177.    
  178.    
  179.     char  a1 = psz[0]%2,
  180.           b1 = psz[1]%2,
  181.           c1 = psz[2]%2,
  182.           d1 = psz[3]%2;
  183.          
  184.          
  185.     if((a1 == 1 and b1 == 1) or (a1 == 0 and b1 == 0 )) printf("B");   
  186.     if((a1 == 1 and b1 == 0) or (a1 == 0 and b1 == 1 )) printf("W");
  187.     if((c1 == 1 and d1 == 1) or (c1 == 0 and d1 == 0 )) printf("B");
  188.     if((c1 == 0 and d1 == 1) or (c1 == 1 and d1 == 0 )) printf("W");
  189. }
  190. */
  191.  
  192.  
  193.  
  194.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement