【拯救小狗】2022-1-3
缘由c++学校练习试题,求解决-编程语言-CSDN问答
void 拯救小狗()
{//缘由https://ask.csdn.net/questions/7622294?spm=1005.2025.3001.5141int d = 0, g = 0, tfh[100][3]{}, x = 0, c = 10, dd = d;std::cin >> d >> g; dd = d;while (x < g && dd > 0){std::cin >> tfh[x][0] >> tfh[x][1] >> tfh[x][2];if (c > tfh[x][0] || (c == tfh[x][0] && dd == tfh[x][2]))dd -= tfh[x][2];elsedd += tfh[x - 1][2], dd -= tfh[x][2], c += tfh[x - 1][1];++x;}if (dd > 0){x = 0, c = 10, dd = d;while (x < g)c += tfh[x][1], ++x;}std::cout << (dd <= 0 ? "拯救时间:" : "存活时间:")<< (dd <= 0 ? tfh[x - 1][0] : c) << ";还有高度" << dd << std::endl;
}