Changeset 90c3b1c for src/examples/sum.c
- Timestamp:
- Mar 2, 2016, 4:59:19 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- bdad1679
- Parents:
- ac1ed49
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/examples/sum.c
rac1ed49 r90c3b1c 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 16 23:49:31201613 // Update Count : 1 8912 // Last Modified On : Wed Mar 2 14:31:45 2016 13 // Update Count : 193 14 14 // 15 15 … … 47 47 a[i] = v; 48 48 } // for 49 sout | "sum from " | low | " to " | High | " is"50 | (int)sum( size, a ) | " , check" | (int)s | endl;49 sout | "sum from" | low | "to" | High | "is" 50 | (int)sum( size, a ) | "" | ", check" | (int)s | endl; 51 51 52 52 int s = 0, a[size], v = low; … … 55 55 a[i] = (int)v; 56 56 } // for 57 sout | "sum from " | low | " to " | High | " is"58 | sum( size, (int *)a ) | " , check" | (int)s | endl;57 sout | "sum from" | low | "to" | High | "is" 58 | sum( size, (int *)a ) | "" | ", check" | (int)s | endl; 59 59 60 60 float s = 0.0, a[size], v = low / 10.0; … … 63 63 a[i] = (float)v; 64 64 } // for 65 sout | "sum from " | low / 10.0 | " to " | High / 10.0 | " is"66 | sum( size, (float *)a ) | " , check" | (float)s | endl;65 sout | "sum from" | low / 10.0 | "to" | High / 10.0 | "is" 66 | sum( size, (float *)a ) | "" | ", check" | (float)s | endl; 67 67 68 68 double s = 0, a[size], v = low / 10.0; … … 71 71 a[i] = (double)v; 72 72 } // for 73 sout | "sum from " | low / 10.0 | " to " | High / 10.0 | " is"74 | sum( size, (double *)a ) | " , check" | (double)s | endl;73 sout | "sum from" | low / 10.0 | "to" | High / 10.0 | "is" 74 | sum( size, (double *)a ) | "" | ", check" | (double)s | endl; 75 75 76 76 struct S { int i, j; } 0 = { 0, 0 }, 1 = { 1, 1 }; … … 79 79 S ++?( S *t ) { *t += 1; return *t; } 80 80 S ?++( S *t ) { S temp = *t; *t += 1; return temp; } 81 ofstream * ?|?( ofstream * os, S v ) { return os | v.i | ' ' |v.j; }81 ofstream * ?|?( ofstream * os, S v ) { return os | v.i | v.j; } 82 82 83 83 S s = 0, a[size], v = { low, low }; … … 86 86 a[i] = (S)v; 87 87 } // for 88 sout | "sum from " | low | " to " | High | " is"89 | sum( size, (S *)a ) | " , check" | (S)s | endl;88 sout | "sum from" | low | "to" | High | "is" 89 | sum( size, (S *)a ) | "" | ", check" | (S)s | endl; 90 90 } // main 91 91
Note: See TracChangeset
for help on using the changeset viewer.