當前位置:編程學習大全網 - 電腦編程 - 3、樗蒲(chp.cpp)編程,看看編編

3、樗蒲(chp.cpp)編程,看看編編

#include <iostream>

using std::cout;

using std::endl;

using std::cin;

#include <vector>

using std::vector;

int main() {

int n, s, t, c = 0;

cin >> n >> s;

vector<int> ints;

while (cin >> t) ints.push_back(t);

for (vector<int>::iterator i = ints.begin(); i != ints.end(); ++i)

for (vector<int>::iterator j = i + 1; j != ints.end(); ++j)

if (*i + *j <= s) ++c;

cout << c << endl;

return 0;

}

  • 上一篇:MCGS如何實現腳本程序的循環
  • 下一篇:請問別克榮禦車保養燈怎麽歸零?
  • copyright 2024編程學習大全網