Skip to content

Commit

Permalink
用比較高效的方法去算 array
Browse files Browse the repository at this point in the history
  • Loading branch information
doremi committed May 28, 2012
1 parent 68dc267 commit 0309a17
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion count.c
Expand Up @@ -2,7 +2,7 @@

int main()
{
int numbers[] = {1, 3, 3, 4, 4, 4, 4, 4};
int numbers[] = {1, 2, 2, 2, 3, 3, 4, 4, 4, 5};
int total = sizeof(numbers) / sizeof(numbers[0]);
int sum = 0;

Expand All @@ -11,6 +11,8 @@ int main()
i = 0;
while (i < total) {
int comp = numbers[i];
sum = numbers[i];
++i;
for (; i < total; ++i) {
int curr = numbers[i];
if (comp == curr) {
Expand Down

0 comments on commit 0309a17

Please sign in to comment.