Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
thermal_containers
#include <stdlib.h> #include <stdio.h> #define HTML(args) printf args /*put // be4 printf to don't get intermediate data in HTML table*/ double cell(double what){ HTML(("\t<td>%f</td>\n", what)); return what; } int main(void){ unsigned containers, x, y; double sum=0, *row; fprintf(stderr, "How many containers?: "); scanf("%u", &containers); HTML(("<table border=3><tr>\n")); row=(double*)malloc(containers*sizeof(double)); row[0]=cell(50); for(x=1; x<containers; ++x) row[x]=cell(row[x-1]/2); HTML(("</tr>")); for(y=1; y<containers; ++y){ HTML(("<tr>\n")); row[0]=cell( (row[0]+100)/2 ); for(x=1; x<containers; ++x) row[x]=cell( (row[x-1]+row[x])/2 ); HTML(("</tr>")); } HTML(("</table>\n")); for(x=0; x<containers; ++x) sum+=row[x]; free(row); HTML(("Final result: ")); printf("%.3f\n", sum/containers); return 0; }
run
|
edit
|
history
|
help
0
Array pass effect
Instruction order in C/C++
SUDOKUS CORRECTOS
150115_EsMatrizOrdenada
22nd HW Switchv0.3
888 BONUS LAB 1
qsort para struct
hello kous
Humko
FUNTION 2