**
14:人口增长问题
**
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int x,n;
cin >> x >>n;
double num = x;
for(int i=0;i<n;i++){
num += 0.001*num;
}
cout << fixed << setprecision(4) <<num;
}
15:银行利息
#include <iostream>
#include <cmath>
using namespace std;
int main(){
double R,M,Y;
cin >> R >> M >> Y;
for(int i=0;i<Y;i++){
M +=M*(R/100);
}
cout <<fixed<< (int)floor(M);
}
floor() 小于这个数的最大整数
seil() 大于这个数的最大整数
round() 四舍五入
还有我不喜欢这个double类型老是1e+啥啥的,请给我立刻改掉,让我提交了三遍才过
16:买房子
我写了个什么捷豹东西?
还写了一个小时,还不对?
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
int main(){
double N,K;
cin >> N >> K;
double myMoe=0;
double moe =200;
int year =0;
for(int i=0;i<20;i++){
moe +=200*(K/100);
myMoe +=N;
if(myMoe >=moe){
if(fmod(myMoe,moe)==0){
year = i+1; goto po;
}
else {year = i+2; goto po;}
}
}
if(myMoe<moe) goto im;
po : cout << year;
exit(0);
im : cout << "impossible";
}
我他吗可真是个鬼才,去问问别人为什么不对了。