Changes in src/examples/sum.c [dd51906:b63e376]
- File:
-
- 1 edited
-
src/examples/sum.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/examples/sum.c
rdd51906 rb63e376 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // sum.c -- test resolvers ability to deal with many variables with the same name and to use the minimum number of casts 8 // necessary to disambiguate overloaded variable names. 7 // sum.c -- 9 8 // 10 9 // Author : Peter A. Buhr 11 10 // Created On : Wed May 27 17:56:53 2015 12 11 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Thu May 26 09:25:42201614 // Update Count : 20112 // Last Modified On : Fri Mar 4 15:06:47 2016 13 // Update Count : 196 15 14 // 16 15 … … 49 48 } // for 50 49 sout | "sum from" | low | "to" | High | "is" 51 | (int)sum( size, a ) | " , check" | (int)s | endl;50 | (int)sum( size, a ) | "" | ", check" | (int)s | endl; 52 51 53 52 int s = 0, a[size], v = low; … … 57 56 } // for 58 57 sout | "sum from" | low | "to" | High | "is" 59 | sum( size, (int *)a ) | " , check" | (int)s | endl;58 | sum( size, (int *)a ) | "" | ", check" | (int)s | endl; 60 59 61 60 float s = 0.0, a[size], v = low / 10.0; … … 65 64 } // for 66 65 sout | "sum from" | low / 10.0 | "to" | High / 10.0 | "is" 67 | sum( size, (float *)a ) | " , check" | (float)s | endl;66 | sum( size, (float *)a ) | "" | ", check" | (float)s | endl; 68 67 69 68 double s = 0, a[size], v = low / 10.0; … … 73 72 } // for 74 73 sout | "sum from" | low / 10.0 | "to" | High / 10.0 | "is" 75 | sum( size, (double *)a ) | " , check" | (double)s | endl;74 | sum( size, (double *)a ) | "" | ", check" | (double)s | endl; 76 75 77 76 struct S { int i, j; } 0 = { 0, 0 }, 1 = { 1, 1 }; 78 S ?+?( S t1, S t2 ) { return (S){ t1.i + t2.i, t1.j + t2.j }; }77 S ?+?( S t1, S t2 ) { S s = { t1.i + t2.i, t1.j + t2.j }; return s; } 79 78 S ?+=?( S *t1, S t2 ) { *t1 = *t1 + t2; return *t1; } 80 79 S ++?( S *t ) { *t += 1; return *t; } … … 88 87 } // for 89 88 sout | "sum from" | low | "to" | High | "is" 90 | sum( size, (S *)a ) | " , check" | (S)s | endl;89 | sum( size, (S *)a ) | "" | ", check" | (S)s | endl; 91 90 } // main 92 91
Note:
See TracChangeset
for help on using the changeset viewer.