@Dave1/

MediumblueVitalNlp

C

No description

fork
loading
Files
  • main.c
  • account1.txt
  • account1out.txt
main.c
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdio.h>

int main(void){

FILE * f_in;

int size, account[100] ={0};

f_in =fopen ("account1.txt","r");


if (f_in == NULL)
printf("could not open the file\n");

else
printf("file has been opened sucessfuly !");


fscanf(f_in,"%d",&size);
printf("%d",size);

for (int i=0;i<size;i++){

int command_type;
int cus_no, amount;

switch(command_type)
{
  case 1:
fscanf (f_in, "%d %d",&cus_no,&amount);
account[cus_no]+=amount;
break;

  case 2:
  fscanf (f_in, "%d %d",&cus_no,&amount);
account[cus_no]-=amount;
break;

  case 3:
  for (int j=0; j<100; j++)
  if (account[j]<0)
  printf("Customer %d, you owe $%d. Please pay immediately !\n",j,-account[j]);
  break;
  default:
  printf("Unknow Command\n");
}

}


fclose(f_in);



}