aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ee1301/wk1/hw1_directory/strap012_1B.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/ee1301/wk1/hw1_directory/strap012_1B.cpp b/ee1301/wk1/hw1_directory/strap012_1B.cpp
index 02fd560..f5a00da 100644
--- a/ee1301/wk1/hw1_directory/strap012_1B.cpp
+++ b/ee1301/wk1/hw1_directory/strap012_1B.cpp
@@ -1,5 +1,6 @@
#include <iostream>
#include <string>
+#include <iomanip>
using namespace std;
int main()
@@ -9,17 +10,23 @@ int main()
cin >> option;
if (option == "i") {
-
- cout << "E";
-
+ int r;
+ int g;
+ int b;
+ cout << "Input r, g, b: ";
+ cin >> r >> g >> b;
+ cout << fixed << setprecision(2) << "Float representation: " << r / 255.0 << ", " << g / 255.0 << ", " << b / 255.0;
}else{ if (option == "f") {
-
- cout << "e";
-
+ double r;
+ double g;
+ double b;
+ cout << "Input r, g, b: ";
+ cin >> r >> g >> b;
+ cout << fixed << setprecision(0) << "Integer representation: " << r * 255 << ", " << g * 255 << ", " << b * 255;
}else{
-
- cout << "Invalid option.";
+ cout << "Invalid option." << endl;
+ return 0;
}
}
- cout << endl;
+ cout << endl;
} \ No newline at end of file