Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions sources/hash_map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <map>
#include <list>
#include <ext/hash_map>

#include<bits/stdc++.h>
/*
* n: number
* i: LSB starting from 1
Expand All @@ -31,34 +31,36 @@ using namespace std;

int test = 0, pass = 0;

void assert(bool result) {
int checks(bool result) {
test++; pass+=result;
cout << (result ? "PASS: " : "FAIL: ");
cout << (result ? "PASS " : "FAIL ")<<"\n";

return 0;
}


int main() {
ios::sync_with_stdio(false);

__gnu_cxx::hash_map<string, int> months;

months["january"] = 31;
months["february"] = 28;
months["march"] = 31;
months["april"] = 30;
months["may"] = 31;
months["june"] = 30;
months["july"] = 31;
months["august"] = 31;
months["september"] = 30;
months["october"] = 31;
months["november"] = 30;
months["december"] = 31;
map<string, int> months;

ASSERT(months["september"]==30)
ASSERT(months["august"]==31)
months["January"] = 31;
months["February"] = 28;
months["March"] = 31;
months["April"] = 30;
months["May"] = 31;
months["June"] = 30;
months["July"] = 31;
months["August"] = 31;
months["September"] = 30;
months["October"] = 31;
months["November"] = 30;
months["December"] = 31;

checks(months["September"]==30);
checks(months["August"]==31);

cout << "Passed: " << pass << " (" << 100.0*pass/test << "%%)" << endl;

return 0;
}
}
Binary file added sources/hash_map.exe
Binary file not shown.
Binary file added sources/hash_map.o
Binary file not shown.
11 changes: 6 additions & 5 deletions sources/list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ using namespace std;

int main() {
list<int> ll;
ll.push_back(1);
ll.push_back(2);
ll.push_back(3);
ll.push_back(4);
int n;
cin>>n;
for(int i=1;i<n;i++)
ll.push_back(i);

cout<<"Resulting list is as follows : \n";
for (list<int>::iterator li = ll.begin(); li != ll.end(); li++) {
cout << *li << endl;
}

return 0;
}
}
Binary file added sources/list.exe
Binary file not shown.
Binary file added sources/list.o
Binary file not shown.