1. Си / Говнокод #24870

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    #include<stdio.h>
    #include<stdlib.h>	
    #include<string.h>		
    struct masterRecord{ int 		Number; char 		Name[20]; char 		Surname[20]; char 		addres[30]; char 		TelNumber[15]; double  	indebtedness; double    	credit_limit;  double  	cash_payments; };
    	typedef  struct  masterRecord Data;
    	int main(void){
    		int choice = 0;	
    		void masterWrite(FILE *ofPTR, Data   Client       )  ,transactionWrite(FILE *ofPTR, Data transfer     )   ,      blackRecord(FILE *ofPTR, FILE  *ofPTR_2 , FILE *blackrecord , Data	 client_data  ,   Data transfer )                    ;
    		FILE *Ptr, *Ptr_2 , *blackrecord   ;
    	  	Data	 client_data,  transfer  ;
    	printf("%s", "please enter action\n1 enter data client:\n2 enter data transaction:\n3 update base\n" );
    			while (		scanf("%d", &choice )  !=  -1   )  {
    				switch(  choice  )  {
    				case	1:
    					Ptr = fopen("record.dat", "r+" );
    						if(Ptr == NULL ){
    						puts("Not acess");	
    						}
    					else{
    							masterWrite(  Ptr , client_data);	
    							fclose(Ptr);
    							}
    					break;
    				case    2:
    					Ptr = fopen("transaction.dat", "r+" );
    						if(Ptr == NULL ){
    						puts("Not acess");	
    						}
    					else{
    						transactionWrite( Ptr, transfer     );
    						fclose(Ptr);
    					}
    					break;	
    				case    3:
    					Ptr = fopen( "record.dat", "r"  );
    					Ptr_2 = fopen("transaction.dat", "r" );
    					blackrecord = fopen("blackrecord.dat", "w" );	
    				if(	Ptr == NULL ||  	Ptr_2 == NULL ||  		blackRecord == NULL      ){
    						puts("exit");
    					}
    					else{
    					blackRecord( Ptr, Ptr_2 , blackrecord  , client_data  ,    transfer );
    					fclose(Ptr);
    					fclose(Ptr_2);	
    					fclose(blackrecord);
    					}
    					break;
    					default:
    					puts("error");
    					break ;
    				}
     	printf("%s", "please enter action\n1 enter data client:\n2 enter data transaction:\n3 update base\n" );
    		}
                return 0;	
    	}
    	void masterWrite(FILE *ofPTR , Data   Client       )  {
    		printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n\n",  
    				"1 Number account: ",
    				"2 Client name: ",
    				"3 Surname: ",
    				"4 Addres client: ",
    				"5 Client Telnum: ",
    				"6 Client indebtedness: ",
    				"7 Client credit limit: ",
    				"8 Client cash payments: " );
    		while(  scanf("%d%s%s%s%s%lf%lf%lf", &Client.Number, Client.Name, Client.Surname, Client.addres, Client.TelNumber, &Client.indebtedness,	&Client.credit_limit ,	&Client.cash_payments    ) != -1     ){
    		fprintf( ofPTR, "%-12d%-11s%-11s%-16s%20s%12.2f%12.2f%12.2f\n", Client.Number, Client.Name, Client.Surname, Client.addres, Client.TelNumber, Client.indebtedness,	Client.credit_limit ,		 	Client.cash_payments    ) ;
    		printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n\n",  
    				"1 Number account: ",
    				"2 Client name: ",
    				"3 Surname: ",
    				"4 Addres client: ",
    				"5 Client Telnum: ",
    				"6 Client indebtedness: ",
    				"7 Client credit limit: ",
    				"9 Client cash payments:"
    										);
    				} }
           void transactionWrite(FILE *ofPtr, Data transfer     ){
    		printf("%s\n%s\n",  
    			"1 Number account: ",
    			"2 Client cash payments: ");
    			while(scanf("%d %lf" , &transfer.Number  , &transfer.cash_payments )   != -1      ){
    				fprintf( ofPtr, "%-3d%-6.2f\n", transfer.Number, 		transfer.cash_payments    ) ;
    				printf("%s\n%s\n",  
    						"1 Number account:",
    						"2 Client cash payments: "
    												);
    			} }
       void blackRecord(FILE *ofPTR, FILE  *ofPTR_2 , FILE *blackrecord , Data	 client_data  ,   Data transfer ){
    	while(fscanf( 	ofPTR  , "%d%s%s%s%s%lf%lf%lf",  &client_data.Number ,  client_data.Name  , client_data.Surname   , client_data.addres, client_data.TelNumber, &client_data.indebtedness, &client_data.credit_limit, &client_data.cash_payments)   != -1 )  {
    			while (	fscanf(	ofPTR_2 , "%d %lf",  &transfer.Number , &transfer.cash_payments       ) 	  !=  -1 ){
    					if(     client_data.Number     ==   transfer.Number   &&  transfer.cash_payments != 0         ){
    						client_data.credit_limit += transfer.cash_payments;
    					} 
    				}
    			fprintf(blackrecord   ,"%-12d%-11s%-11s%-16s%20s%12.2f%12.2f%12.2f\n", client_data.Number, client_data.Name, client_data.Surname, client_data.addres, client_data.TelNumber, client_data.indebtedness,	client_data.credit_limit ,  client_data.cash_payments    ) ;
    			rewind(	ofPTR_2 );
    		} }

    В новом Сорокине мне больше всего понравились "Фиолетовые лебеди".

    Запостил: tyrin, 07 Октября 2018

    Комментарии (52) RSS

    Добавить комментарий