forked from pezy/CppPrimer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
192 additions
and
55 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
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,28 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main(void) | ||
{ | ||
char c; | ||
int aCnt = 0, eCnt = 0, iCnt = 0, oCnt = 0, uCnt = 0; | ||
while (cin >> c) | ||
{ | ||
if (c == 'a' || c == 'A') | ||
++aCnt; | ||
else if (c == 'e' || c == 'E') | ||
++eCnt; | ||
else if (c == 'i' || c == 'I') | ||
++iCnt; | ||
else if (c == 'o' || c == 'O') | ||
++oCnt; | ||
else if (c == 'u' || c == 'U') | ||
++uCnt; | ||
} | ||
cout << "Num of vowel a : " << aCnt << endl; | ||
cout << "Num of vowel e : " << eCnt << endl; | ||
cout << "Num of vowel i : " << iCnt << endl; | ||
cout << "Num of vowel o : " << oCnt << endl; | ||
cout << "Num of vowel u : " << uCnt << endl; | ||
return 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,11 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main(void) | ||
{ | ||
int a, b; | ||
cin >> a >> b; | ||
cout << static_cast<double>(a) / b << endl; | ||
|
||
return 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 |
---|---|---|
|
@@ -36,7 +36,7 @@ int main() | |
|
||
while(cin>>n1>>n2) | ||
{ | ||
if(n2==1) | ||
if(n2==0) | ||
{ | ||
try | ||
{ | ||
|
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,15 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main(void) | ||
{ | ||
int a, b; | ||
cin >> a >> b; | ||
|
||
if (b == 0) | ||
throw runtime_error("divisor is 0"); | ||
|
||
cout << static_cast<double>(a) / b << endl; | ||
|
||
return 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,34 @@ | ||
#include <iostream> | ||
#include <stdexcept> | ||
|
||
using namespace std; | ||
|
||
int main(void) | ||
{ | ||
int a, b; | ||
cout << "Enter two numbers :" << endl; | ||
|
||
while (cin >> a >> b) | ||
{ | ||
try{ | ||
if (b == 0) | ||
throw runtime_error("divisor is 0"); | ||
cout << static_cast<double>(a) / b << endl; | ||
break; | ||
} | ||
catch (runtime_error err){ | ||
cout << err.what() | ||
<< "\nTry again ? Enter y or n" << endl; | ||
char c; | ||
cin >> c; | ||
if (!cin || c == 'n') | ||
break; | ||
else | ||
{ | ||
cout << "Enter two numbers :" << endl; | ||
} | ||
} | ||
} | ||
|
||
return 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,23 @@ | ||
#include <iostream> | ||
#include <initializer_list> | ||
|
||
using namespace std; | ||
|
||
int add(initializer_list<const int> il); | ||
|
||
int main(void) | ||
{ | ||
int result = add({ 1, 2, 3, 4, 5 }); | ||
|
||
cout << result << endl; | ||
|
||
return 0; | ||
} | ||
|
||
int add(initializer_list<const int> il) | ||
{ | ||
int sum = 0; | ||
for (auto a : il) | ||
sum += a; | ||
return sum; | ||
} |
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
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
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
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
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
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
Oops, something went wrong.