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