Skip to content

Commit 313121f

Browse files
committed
Add sample solution.
1 parent 8c42467 commit 313121f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tools/ccauto/lb-14-arrays.php

+18
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,24 @@ function ccauto_require($LAUNCH) {
9898
// Make sure to escape \n as \\n
9999
function ccauto_solution($LAUNCH) {
100100
return <<< EOF
101+
#include <stdio.h>
102+
int main() {
103+
int i, v, arr[10], count;
104+
for(i=0;i<10;i++) {
105+
scanf("%d", &v);
106+
arr[i] = v;
107+
}
108+
for(i=9; i>=0; i-- ) printf("numb[%d] = %d\\n",i, arr[i]);
109+
110+
printf("\\nSearching for entries equal to 100\\n\\n");
111+
count = 0;
112+
for(i=0;i<10;i++) {
113+
if ( arr[i] != 100 ) continue;
114+
count++;
115+
printf("Found 100 at %d\\n", i);
116+
}
117+
printf("\\nFound %d entries with 100\\n", count);
118+
}
101119
EOF
102120
;
103121
}

0 commit comments

Comments
 (0)