Advertisement
whoisbsa

exercicio 1

Nov 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. ///Exercicio 01:
  2.  
  3. int main()
  4. {
  5.     int i, v[4] = {1, 1, 1};
  6.  
  7.     for (i=0; i<3; i++){
  8.         printf("%d ", v[i]);
  9.     }
  10.     printf("\n\n");
  11.     digCtrl(v);
  12.     for (i=0; i<4; i++){
  13.         printf("%d ", v[i]);
  14.     }
  15.  
  16.     return 0;
  17. }
  18.  
  19. int digCtrl(int v[])
  20. {
  21.     int i, a, b, c, dc;
  22.  
  23.     for (i=0; i<4; i++){
  24.         if(i==0){
  25.             v[3] = v[0]+3;
  26.             a = v[3];
  27.         }
  28.         else if(i==1){
  29.             v[3] = v[1]+5;
  30.             b = v[3];
  31.         }
  32.         else if (i==2){
  33.             v[3] = v[2];
  34.             c = v[3];
  35.         }else{
  36.             v[3] = (a*b*c)%3;
  37.         }
  38.     }
  39.     return v[3];
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement