#include <iostream>
using namespace std;
int main(){
cout << "I love programming." << endl;
return 0;
}
#include <iostream>
using namespace std;
int main(){
cout << 20 / 7 << endl;
cout << 20 % 7 << endl;
return 0;
}
#include <iostream>
using namespace std;
int main(){
cout << 9/8 << 4*(6+3)%5 << (4*6+3)%5 << endl;
return 0;
}
#include <iostream>
using namespace std;
int main(){
cout << 9/8 << 4*(6+3)%5 << (4*6+3)%5 << endl;
cout << 9/8 << " " << 4*(6+3)%5 << " " << (4*6+3)%5 << endl;
cout << "9/8=" << 9/8 << " 4*(6+3)%5=" << 4*(6+3)%5 << " (4*6+3)%5=" << (4*6+3)%5 << endl;
return 0;
}
#include <iostream>
using namespace std;
int main(){
cout << "8000秒=";
cout << 8000/3600 << "小时";
cout << (8000%3600)/60 << "分钟";
cout << 8000%3600%60 << "秒";
cout << endl;
return 0;
}
#include <iostream>
using namespace std;
int main(){
cout << "5个工人6天能铺";
cout << 90.0/3/4*5*6 << " 平方米地板砖。" << endl;
return 0;
}
#include <iostream>
using namespace std;
int main(){
cout << 15*3/2 << endl;
cout << 15*3/2.0 << endl;
return 0;
}
fixed << setprescision(8)
格式函数的作用。
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
cout << "9/8=" << 9/8;
cout << " 9.0/8=" << 9.0/8;
cout << " 9/8.0=" << 9/8.0;
cout << " 9.0/8.0=" << 9.0/8.0;
cout << endl;
cout << "10.0/6.0=" << 10.0/6.0 << endl;
cout << "10.0/6.0=" << fixed << setprecision(8) << 10.0/6.0 << endl;
return 0;
}
#include <iostream>
using namespace std;
int main(){
cout << (90/3/3)*5*6 << endl;
return 0;
}
#include <iostream>
using namespace std;
int main(){
cout << 105 / 7 / (100/5/4) << endl;
return 0;
}
#include <iostream>
using namespace std;
int main(){
int a,b;
a = 58 / 8;
b = 58 - a * 8;
cout << "需要去掉 " << b << " 根,每班分到 " << a << " 根。" << endl;
return 0;
}
#include <iostream>
using namespace std;
int main(){
cout << 0.6/5*16 << endl;
return 0;
}
#include <iostream>
using namespace std;
int main(){
cout << 3.2 * 791 / 2.8 << endl;
return 0;
}
#include <iostream>
#include <cmath>
using namespace std;
int main(){
cout << sqrt(10*8-16) << endl;
return 0;
}