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
		
			
				
	
	
		
			47 lines
		
	
	
		
			859 B
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			859 B
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
| #include <stdio.h>
 | |
| #include "gm.h"
 | |
| void	getdec(char *,DEC *);
 | |
| void main(void);
 | |
| 
 | |
| void	main()
 | |
| {
 | |
| 	DEC	book[1], salv[1], partial[1];
 | |
| 	DEC	*depr[50], *remval[50];
 | |
| 	int	life, i;
 | |
| 	
 | |
| 	printf("Sum of years digits depreciation\n");
 | |
| 
 | |
| 	getdec("Book value:  ", book);
 | |
| 	getdec("Salvage value:  ", salv);
 | |
| 	printf("Lifetime of asset (years):  ");
 | |
| 	dscanf("%d", &life);
 | |
| 
 | |
| 	ZeroDecimal(partial);
 | |
| 	
 | |
| 	AllocateDecimalArray(depr, life+1);
 | |
| 	AllocateDecimalArray(remval, life+1);
 | |
| 
 | |
| 	DepreciateSumOfYearsTable(depr, remval, book,
 | |
| 		salv, life, partial); 
 | |
| 	printf("%20s%20s%20s\n", "Year #",
 | |
| 		"Depreciation", "Remaining Value");
 | |
| 	for (i=1; i<=life; i++)
 | |
| 		dprintf("%20d%20v%20v\n", i,
 | |
| 			depr[i], remval[i]);
 | |
| 		
 | |
| 	FreeDecimalArray(depr);
 | |
| 	FreeDecimalArray(remval);
 | |
| }
 | |
| 
 | |
| void	getdec(str, x)
 | |
| char	*str;
 | |
| DEC	*x;
 | |
| {
 | |
| 	int	i;
 | |
| 	
 | |
| 	do  {
 | |
| 		printf("%s", str);
 | |
| 		i = dscanf("%t", x);
 | |
| 	} while (i<1);
 | |
| }
 |