C++ 小鱼游泳计算 - 累计里程算法
#include
int main(){ int x, n; cin >> x >> n;
int totalDistance = 0;
int currentDay = x; // 当前是周几
for(int i=0; i<n; i++){
// 判断是否是周末
if(currentDay == 6 || currentDay == 7){
// 周末休息
continue;
}
// 上午游泳150公里
totalDistance += 150;
// 下午游泳100公里
totalDistance += 100;
// 更新当前是周几
currentDay = (currentDay + 1) % 7;
}
cout << totalDistance << endl;
return 0;
}
原文地址: https://www.cveoy.top/t/topic/qztJ 著作权归作者所有。请勿转载和采集!