forked from ShujiaHuang/Cpp-Primer-Plus-6th
-
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
1 parent
3a8fd34
commit 511f1be
Showing
7 changed files
with
416 additions
and
13 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
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 @@ | ||
// Create by Shujia Huang on 2021-08-03 | ||
#include <iostream> | ||
#include <cctype> | ||
|
||
|
||
int main() { | ||
using namespace std; | ||
char ch; | ||
|
||
cout << "Enter any charater: "; | ||
while ((ch=cin.get()) != '@') { | ||
|
||
if (isdigit(ch)) { | ||
continue; | ||
} else if (islower(ch)) { | ||
ch = toupper(ch); | ||
} else if (isupper(ch)) { | ||
ch = tolower(ch); | ||
} | ||
|
||
cout << ch; | ||
|
||
} | ||
|
||
cout << "** done **" << 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 @@ | ||
// Create by Shujia Huang on 2021-08-03 | ||
#include <iostream> | ||
#include <array> | ||
|
||
|
||
int main() { | ||
using namespace std; | ||
|
||
const unsigned int size = 10; | ||
array<double, size> donation; | ||
|
||
double sum_value = 0; | ||
unsigned int large_avg = 0, n = 0; | ||
|
||
cout << "Enter 10 double value or type non-digital value to exit: "; | ||
while ((n < size) && (cin >> donation[n])) { | ||
|
||
sum_value += donation[n]; | ||
++n; | ||
} | ||
|
||
double avg = sum_value / n; | ||
for (int i=0; i < n; i++) { | ||
|
||
if (donation[i]>avg) | ||
++large_avg; | ||
} | ||
|
||
cout << "The average value is: " << avg | ||
<< ", there are " << large_avg | ||
<< " larger than average value." << endl; | ||
|
||
return 0; | ||
} |
Oops, something went wrong.