Changes in src/examples/sum.c [cf16f94:784deab]
- File:
-
- 1 edited
-
src/examples/sum.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/examples/sum.c
rcf16f94 r784deab 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Nov 21 18:08:18 201513 // Update Count : 1 1912 // Last Modified On : Mon Jan 4 07:40:24 2016 13 // Update Count : 126 14 14 // 15 15 16 extern "C" {17 int printf( char *, ... );18 }19 16 #include "fstream.h" 20 17 … … 41 38 char ?++( char *op ) { char temp = *op; *op += 1; return temp; } 42 39 43 int main( ) {40 int main( void ) { 44 41 const int low = 5, High = 15, size = High - low; 45 42 … … 52 49 a[i] = v; 53 50 } 54 sout << "sum from " << low << " to " << High <<" is "55 << (int)sum( size, a ) << ", check " << (int)s <<endl;51 sout | "sum from " | low | " to " | High | " is " 52 | (int)sum( size, a ) | ", check " | (int)s | endl; 56 53 57 54 int s = 0, a[size]; … … 61 58 a[i] = (int)v; 62 59 } 63 sout << "sum from " << low << " to " << High <<" is "64 << sum( size, (int *)a ) << ", check " << (int)s <<endl;60 sout | "sum from " | low | " to " | High | " is " 61 | sum( size, (int *)a ) | ", check " | (int)s | endl; 65 62 66 63 double s = 0.0, a[size]; … … 70 67 a[i] = (double)v; 71 68 } 72 printf( "%g\n", sum( size, (double *)a ) ); 73 // sout << "sum from " << low / 10.0 << " to " << High / 10.0 << " is " 74 // << sum( size, (double *)a ) << ", check " << (double)s << endl; 69 sout | "sum from " | low / 10.0 | " to " | High / 10.0 | " is " 70 | sum( size, (double *)a ) | ", check " | (double)s | endl; 75 71 76 72 float s = 0.0, a[size]; … … 80 76 a[i] = (float)v; 81 77 } 82 printf( "%g\n", sum( size, (float *)a ) ); 83 // sout << "sum from " << low / 10.0 << " to " << High / 10.0 << " is " 84 // << sum( size, (float *)a ) << ", check " << (float)s << endl; 78 sout | "sum from " | low / 10.0 | " to " | High / 10.0 | " is " 79 | sum( size, (float *)a ) | ", check " | (float)s | endl; 85 80 } 86 81 87 82 // Local Variables: // 88 83 // tab-width: 4 // 89 // compile-command: "cfa sum.c fstream.o iostream.o " //84 // compile-command: "cfa sum.c fstream.o iostream.o iterator.o" // 90 85 // End: //
Note:
See TracChangeset
for help on using the changeset viewer.