示例#1
0
float mul( CLIENT *clnt, float x, float y) {
  operands ops;
  float *result;

  /* Gather everything into a single data structure to send to the server */
  ops.x = x;
  ops.y = y;

  /* Call the client stub created by rpcgen */
  result = mul_1(&ops,clnt);
  if (result==NULL) {
    fprintf(stderr,"Trouble calling remote procedure\n");
    exit(0);
  }
  return(*result);
}
示例#2
0
void
calccompprog_1(char *host)
{
	CLIENT *clnt;
	int  *result_1;
	complexe  add_1_arg;
	int  *result_2;
	complexe  mul_1_arg;
	void  *result_3;
	complexe  init_1_arg;

#ifndef	DEBUG
	clnt = clnt_create (host, CALCCOMPPROG, CALCVERS, "udp");
	if (clnt == NULL) {
		clnt_pcreateerror (host);
		exit (1);
	}
#endif	/* DEBUG */
	add_1_arg.pentiere = 2;
	add_1_arg.pimaginaire = 0.5;
	result_1 = add_1(&add_1_arg, clnt);
	if (result_1 == (int *) NULL) {
		clnt_perror (clnt, "call failed");
	}

	mul_1_arg.pentiere = 3;
	mul_1_arg.pimaginaire = 1.5;
	result_2 = mul_1(&mul_1_arg, clnt);
	if (result_2 == (int *) NULL) {
		clnt_perror (clnt, "call failed");
	}

	init_1_arg.pentiere = 4;
	init_1_arg.pimaginaire = 2.5;
	result_3 = init_1(&init_1_arg, clnt);
	if (result_3 == (void *) NULL) {
		clnt_perror (clnt, "call failed");
	}

	printf("ADD result : %d", *result_1);
	printf("MUL result : %d", *result_2);
#ifndef	DEBUG
	clnt_destroy (clnt);
#endif	 /* DEBUG */
}
示例#3
0
int main() {
	while ((~scanf("%d %d %d", &a, &b, &n)) && a) {
		f.a = a;
		f.b = b;
		f.c = 1;
		f.d = 0;
		ans.a = 1;
		ans.b = 1;
		index = n - 2;
		if (1 > index) {
			printf("1\n");
		} else {
			while (0 != index) {
				if (0 != (index % 2)) {
					ans = mul_1(f, ans);
				}
				index = index / 2;
				f = mul_2(f, f);
			}
			printf("%d\n", ans.a);
		}
	}
	return 0;
}