zoukankan      html  css  js  c++  java
  • 2.3发帖水王

     1 #include <iostream>
    2 using namespace std;
    3
    4 #include <stdlib.h>
    5 #include <sys/types.h>
    6
    7 int Count(int * a, int n)
    8 {
    9 int count = 0;
    10 int candidate = a[0];
    11 while (n) {
    12 if (count == 0) {
    13 candidate = a[n-1];
    14 ++count;
    15 } else if (candidate == a[n - 1]) {
    16 ++count;
    17 } else {
    18 --count;
    19 }
    20 --n;
    21 }
    22 return candidate;
    23 }
    24
    25 int main()
    26 {
    27 const int n = 7;
    28 int a[n] = {1, 1, 1, 1, 2, 3, 4};
    29 cout << Count(a, n) << endl;
    30
    31 return 0;
    32 }
  • 相关阅读:
    心得
    第七章
    第六章
    第五章
    第四章
    第三章
    第二章
    第一章
    实验2(4)
    实验2(3)
  • 原文地址:https://www.cnblogs.com/tzhangofseu/p/2220332.html
Copyright © 2011-2022 走看看