记一次失败的笔试(华为研发工程师-汽水瓶笔试题)
Posted wasua
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了记一次失败的笔试(华为研发工程师-汽水瓶笔试题)相关的知识,希望对你有一定的参考价值。
#include<iostream> #include<fstream> using namespace std; int comp(int buttle, int current, int &drink); int main(void) int n[10] = 0,0,0,0,0,0,0,0,0,0 ; int N,i=0; ifstream infile("test.txt", ios::in); while (infile >> N) n[i++] = N; for (int j = 0; n[j] != 0; j++) int buttle = n[j]; int drink = 0; int flag = comp(buttle, 0, drink); if (flag == 1) int i = drink; drink = i + 1; cout << drink << endl; return 0; system("pause"); int comp(int buttle, int current, int &drink) current += buttle / 3; drink += current; buttle = buttle % 3+current; if (buttle < 2) return 0; else if (buttle == 2) return 1; else current = 0; return comp(buttle, current, drink);
##做事不过脑子,还是太菜了!!!
以上是关于记一次失败的笔试(华为研发工程师-汽水瓶笔试题)的主要内容,如果未能解决你的问题,请参考以下文章