Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Implement a structure for Transaction where you store the date of the transaction (day, month and year), amount (integer) and currency (char array of 3 chars). (10 points)
- Write a main function where you read an integer N (max 500) and then read data for N transactions (each in new line in the following format: dd/mm/yyyy amount currency). (10 points)
- Example:
- 18/03/2016 310 MKD
- Print on the SO all the transactions with currency MKD that have amount greater then 1000 and were completed in the period from 01.01.2013 to 31.12.2015. (15 points)
- Print the total amount of these transactions. (5 points)
- For the printing format see the output of the first test sample.
- ---------------------------------------------------------------------------------------------------------------------------------------
- #include <stdio.h>
- #include <string.h>
- typedef struct Transaction
- {
- int day;
- int month;
- int year;
- int ammount;
- char currency[3];
- }Transaction;
- void function(int n)
- {
- int i;
- Transaction t[500];
- for(i=0; i<n;i++)
- {
- scanf("%2d/%2d/%4d %d %3s",&t[i].day,&t[i].month,&t[i].year,&t[i].ammount,&t[i].currency[3]);
- }
- int j,sum=0;
- for(j=0;j<n;j++)
- {
- if(strcmp(t[j].currency,"MKD")&&t[j].ammount>1000 && (t[j].year<2013 || t[j].year>2015)==0)
- {
- sum+=t[j].ammount;
- printf("%d. %02d/%02d/%d %d %s\n",j,t[j].day,t[j].month,t[j].year,t[j].ammount,"MKD");
- }
- }
- printf("Total: %d %s",sum,"MKD");
- }
- int main()
- {
- int n;
- scanf("%d",&n);
- Transaction p;
- function(n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement