用c++编程 有1020个西瓜,第一天买一半多两个,以后每天卖剩下的一半多两个,玩几天买完? 要程序框图
#include<iostream>
using namespace std;
int main(){
int total= 1024;
int day = 0; // calculate days
for(int i = 0;;i++){
total = (total/2 - 2); // every data seal half and two more
day++; // count sealing day
if(total == 0)break; // if nothing to seal, stop for loop
}
cout<<day<<endl; //display the day asking
return 0;
}
标签:一半多,c++