Skip to content

Instantly share code, notes, and snippets.

@andraantariksa
Created April 18, 2019 07:05
Show Gist options
  • Save andraantariksa/bf2cbcc976a1ae5aacb14d76c3261ef2 to your computer and use it in GitHub Desktop.
Save andraantariksa/bf2cbcc976a1ae5aacb14d76c3261ef2 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
struct Date {
short hour, minute, date, month, year;
};
struct Customer{
std::string name, address;
char gender;
float discount;
std::vector<Date> transaction;
};
int main(int argc, const char *argv[]){
Customer customer[2];
customer[0].name = "David E. Winn";
customer[0].address = "2431 Heron Way Carlton, OR 97111";
customer[0].gender = 'M';
customer[0].discount = 20.00;
customer[0].transaction.push_back(Date{
12, 0, 1, 1, 2019
});
customer[0].transaction.push_back(Date{
14, 22, 3, 2, 2019
});
customer[1].name = "Marvin M. Moy";
customer[1].address = "4279 New Street Lebanon, OR 97111";
customer[1].gender = 'M';
customer[1].discount = 16.00;
customer[1].transaction.push_back(Date{
6, 15, 3, 4, 2019
});
customer[1].transaction.push_back(Date{
17, 34, 3, 5, 2019
});
for (int i = 0; i < 2; i++) {
std::cout << "Customer no. " << i+1 <<'\n';
std::cout << "Name: " << customer[i].name << '\n';
std::cout << "Address: " << customer[i].address << '\n';
std::cout << "Gender: " << customer[i].gender << '\n';
std::cout << "Discount: " << customer[i].discount << '\n';
std::cout << "Trasaction ever made:\n";
for (auto date = customer[i].transaction.begin(); date != customer[i].transaction.end(); date++) {
std::cout << "- " << date->hour << ':' << date->minute << ' ' << date->date << '-' << date->month << '-' << date->year << '\n';
}
std::cout << '\n';
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment