Files correlati : Ricompilazione Demo : [ ] Commento : Aggiunti i sorgenti per Greenleaf Math Library (gfm.dll) git-svn-id: svn://10.65.10.50/trunk@10079 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			57 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
| #include <stdio.h>
 | |
| #include "gm.h"
 | |
| void	printres(char *,DEC *);
 | |
| void main(void);
 | |
| 
 | |
| void main()
 | |
| {
 | |
| 	DECP	x, y, z;
 | |
| 	DEC	*p;
 | |
| 	char	s[40];
 | |
| 
 | |
| 	do  {
 | |
| 		printf(" First number (x) :  ");
 | |
| 		scanf("%s", s);
 | |
| 		p = ConvAsciiToDecimal(x, s);
 | |
| 	} while (!p);
 | |
| 	do  {
 | |
| 		printf("Second number (y) :  ");
 | |
| 		scanf("%s", s);
 | |
| 		p = ConvAsciiToDecimal(y, s);
 | |
| 	} while (!p);
 | |
| 	
 | |
| 	printres("x = ", x);
 | |
| 	printres("y = ", y);
 | |
| 	p = AddDecimal(z, x, y);
 | |
| 	printres("x + y = ", p);
 | |
| 	p = SubtractDecimal(z, x, y);
 | |
| 	printres("x - y = ", p);
 | |
| 	p = MultiplyDecimal(z, x, y);
 | |
| 	printres("x * y = ", p);
 | |
| 	p = DivideDecimal(z, x, y);
 | |
| 	printres("x / y = ", p);
 | |
| 	p = MultiplyDecimalAndRound(z, x, y, 2);
 | |
| 	printres("x * y (rounded) = ", p);
 | |
| 	p = MultiplyDecimalAndTruncate(z, x, y, 2);
 | |
| 	printres("x * y (truncated) = ", p);
 | |
| 	p = DivideDecimalAndRound(z, x, y, 2);
 | |
| 	printres("x / y (rounded) = ", p);
 | |
| 	p = DivideDecimalAndTruncate(z, x, y, 2);
 | |
| 	printres("x / y (truncated) = ", p);
 | |
| }
 | |
| 
 | |
| void	printres(str, pd)
 | |
| char	*str;
 | |
| DEC	*pd;
 | |
| {
 | |
| 	char	sd[22];
 | |
| 
 | |
| 	printf("%20s", str);
 | |
| 	if (pd)  {
 | |
| 		ConvDecimalToAscii(sd, pd);
 | |
| 		printf("%s\n", sd);
 | |
| 	}
 | |
| 	else
 | |
| 		printf("undefined\n");
 | |
| }
 |