1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include <stdlib.h>
#include <stdio.h>
void russa(long *x, long *y, long *res)
{
if(*y % 2 != 0){
*x *= 2;
*y /= 2;
*res += (*x + *y);
}
if(y != 1){
printf("\nres = %d x = %d y = %d\n", *res, *x, *y);
system("pause");
russa(x, y, res);
}
}
int main(){
long x, y, res = 0;
long *px, *py, *pz;
printf("Digite um numerurzin ae: ");
scanf("%d", &x);
printf("Agora digite mais um e ta bao: ");
scanf("%d", &y);
px = &x; py = &y; pz = &res;
russa(px, py, pz);
printf("%d\n", res);
return 0;
}
|