Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
thermal_containers
#include <iostream> #include <iomanip> #include <vector> using std::cout; #define HTML(what) cout << what //place //before cout to don't get intermediate data in HTML table template<typename T> inline const T& cell(const T& what){ HTML("\t<td>"<<what<<"</td>\n"); return what; } int main(){ std::clog << "How many containers?: "; unsigned containers; std::cin >> containers; HTML("<table border=3><tr>\n"); std::vector<double> row(containers); row[0]=cell(50); for(unsigned i=1; i<containers; ++i) row[i]=cell(row[i-1]/2); HTML("</tr>"); for(unsigned y=1; y<containers; ++y){ HTML("<tr>\n"); row[0]=cell( (row[0]+100)/2 ); for(unsigned x=1; x<containers; ++x) row[x]=cell( (row[x-1]+row[x])/2 ); HTML("</tr>"); } HTML("</table>\n"); double sum=0; for(double i:row) sum+=i; HTML("Final result: "); cout << std::fixed << std::setprecision(3) << (sum/containers) << '\n'; }
run
|
edit
|
history
|
help
0
C++ object lifecycle example
3
MeanSDVar
int divide by int
unicodeのテスト
Hello
Finalproject
Proyecto 1
MapGrocery
namelookup