-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructure according to Fall 1403 calendar
- Loading branch information
Showing
372 changed files
with
158,611 additions
and
437 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
.DS_Store | ||
*.out | ||
**/notes | ||
**/recitation |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <iostream> | ||
#include <string> | ||
using namespace std; | ||
|
||
int main() { | ||
string s = "abcdef"; | ||
cout << s.length() << endl; | ||
cout << s[2] << endl; | ||
|
||
cout << s.substr(1, 2) << endl; | ||
cout << s.substr(1) << endl; | ||
|
||
cout << s.find('c') << endl; | ||
if (s.find('D') == string::npos) | ||
cout << "Not found!" << endl; | ||
|
||
return 0; | ||
} |
File renamed without changes.
0
01_Basics/compile-run.sh → 01_TerminalIO_Strings/compile-run.sh
100755 → 100644
File renamed without changes.
0
01_Basics/exit-test.sh → 01_TerminalIO_Strings/exit-test.sh
100755 → 100644
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
02_Vectors/03_VectorLoop.cpp → ...ntainers_Iterators/03_VectorIteration.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <vector> | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main() { | ||
vector<int> v = {1, 3, 6, 2}; | ||
|
||
vector<int>::iterator it = v.begin(); | ||
while (it != v.end()) { | ||
cout << *it << ' '; | ||
++it; | ||
} | ||
cout << endl; | ||
|
||
for (auto it2 = v.begin(); it2 != v.end(); it2++) | ||
cout << *it2 << ' '; | ||
cout << endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <list> | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main() { | ||
list<int> l = {1, 3, 6, 2}; | ||
|
||
list<int>::iterator it = l.begin(); | ||
while (it != l.end()) { | ||
cout << *it << ' '; | ||
++it; | ||
} | ||
cout << endl; | ||
|
||
l.push_front(12); | ||
for (auto it2 = l.begin(); it2 != l.end(); it2++) | ||
cout << *it2 << ' '; | ||
cout << endl; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <vector> | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
vector<double> v; | ||
for (int i = 0; i < 20; i++) { | ||
cout << i << "\tsize = " << v.size() | ||
<< "\tcapacity = " << v.capacity() << endl; | ||
v.push_back(0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <vector> | ||
#include <list> | ||
#include <iostream> | ||
#include <chrono> | ||
|
||
using namespace std; | ||
using namespace chrono; | ||
|
||
int main() | ||
{ | ||
vector<double> v; | ||
for (int i = 0; i < 10000; i++) { | ||
cout << i << "\tsize = " << v.size() | ||
<< "\tcapacity = " << v.capacity(); | ||
|
||
steady_clock::time_point begin = steady_clock::now(); | ||
v.push_back(0); | ||
steady_clock::time_point end = steady_clock::now(); | ||
cout << "\ttime = " << duration_cast<nanoseconds>(end-begin).count() << "[ns]" << endl; | ||
} | ||
|
||
list<double> l; | ||
for (int i = 0; i < 10000; i++) { | ||
cout << i << "\tsize = " << l.size(); | ||
|
||
steady_clock::time_point begin = steady_clock::now(); | ||
l.push_back(0); | ||
steady_clock::time_point end = steady_clock::now(); | ||
cout << "\ttime = " << duration_cast<nanoseconds>(end-begin).count() << "[ns]" << endl; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <vector> | ||
#include <list> | ||
#include <iostream> | ||
#include <chrono> | ||
|
||
using namespace std; | ||
using namespace chrono; | ||
|
||
int main() | ||
{ | ||
vector<double> v; | ||
for (int i = 0; i < 10000; i++) { | ||
cout << i << "\tsize = " << v.size() | ||
<< "\tcapacity = " << v.capacity(); | ||
|
||
steady_clock::time_point begin = steady_clock::now(); | ||
v.push_back(0); | ||
steady_clock::time_point end = steady_clock::now(); | ||
cout << "\ttime = " << duration_cast<nanoseconds>(end-begin).count() << "[ns]" << endl; | ||
} | ||
|
||
list<double> l; | ||
for (int i = 0; i < 10000; i++) { | ||
cout << i << "\tsize = " << l.size(); | ||
|
||
steady_clock::time_point begin = steady_clock::now(); | ||
l.push_back(0); | ||
steady_clock::time_point end = steady_clock::now(); | ||
cout << "\ttime = " << duration_cast<nanoseconds>(end-begin).count() << "[ns]" << endl; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <map> | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
map<string, double> grades; | ||
grades["Hooshang"] = 12.3; | ||
grades["Mahvash"] = 16; | ||
|
||
cout << grades["Hooshang"] << endl; | ||
cout << grades["Esfandiar"] << endl; | ||
// cout << grades.at("Shahnaz") << endl; | ||
cout << grades.size() << endl; | ||
|
||
for (auto it = grades.begin(); it != grades.end(); it++) | ||
cout << it->first << "'s grade is " << it->second << endl; | ||
|
||
map<char, int> cc = {{'a', 4}, {'x', 3}, {'i', 1}}; | ||
for (auto it2 = cc.begin(); it2 != cc.end(); it2++) | ||
cout << it2->first << "->" << it2->second << endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <iostream> | ||
#include <vector> | ||
#include <string> | ||
#include <list> | ||
#include <algorithm> | ||
using namespace std; | ||
|
||
int main() { | ||
vector<int> v = {1, 3, 2, 6, 12, 8}; | ||
list<string> l = {"Gholi", "aroosi", "naraft!"}; | ||
|
||
vector<int>::iterator it = find(v.begin(), v.end(), 6); | ||
if (it != v.end()) | ||
cout << "found!" << endl; | ||
|
||
if (find(l.begin(), l.end(), "Gholi") != l.end()) | ||
cout << "found!" << endl; | ||
|
||
// The following line causes a compile error! How can we fix it? | ||
replace(l.begin(), l.end(), "Gholi", "Shahpar"); | ||
|
||
for (auto it = l.begin(); it != l.end(); it++) | ||
cout << *it << ' '; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <list> | ||
#include <algorithm> | ||
using namespace std; | ||
|
||
int main() { | ||
list<string> l = {"Gholi", "aroosi", "naraft!"}; | ||
|
||
replace(l.begin(), l.end(), string("Gholi"), string("Shahpar")); | ||
|
||
for_each(l.begin(), l.end(), [](string s){ cout << s << ' '; }); | ||
|
||
// for (auto it = l.begin(); it != l.end(); it++) | ||
// cout << *it << ' '; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <list> | ||
#include <algorithm> | ||
using namespace std; | ||
|
||
int main() { | ||
list<string> l = {"Gholi", "aroosi", "naraft!"}; | ||
|
||
auto it = find_if(l.begin(), l.end(), [](string s){ return s.length() % 2 == 1; }); | ||
if (it != l.end()) | ||
cout << *it << endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <list> | ||
#include <algorithm> | ||
using namespace std; | ||
|
||
int main() { | ||
list<string> l = {"Gholi", "aroosi", "naraft!"}; | ||
|
||
auto it = find_if(l.rbegin(), l.rend(), [](string s){ return s.length() % 2 == 1; }); | ||
if (it != l.rend()) | ||
cout << *it << endl; | ||
} |
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.