本页面包含课程例题、课后拓展5关、代码填空4关的完整答案与家长辅导建议。
请输入本讲访问密码:
课程辅导解析(家长端) · 含全部例题、拓展、代码填空答案
#include <iostream>
using namespace std;
int main() {
int nian, yue, ri;
cin >> nian >> yue >> ri; // 读入三个整数
cout << nian << "-" << yue << "-" << ri;
// 输入 2024 2 12 → 输出 2024-2-12
return 0;
}
#include <iostream>
using namespace std;
int main() {
int a = 25;
int b;
cin >> b;
cout << a / b << endl; // 商:25除以b的整数商
cout << a % b; // 余数:25除以b的余数
// 输入10 → 输出 2(商)换行 5(余数)
return 0;
}
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
cout << n / 100 << endl; // 百位:123/100=1
cout << n / 10 % 10 << endl; // 十位:123/10=12, 12%10=2
cout << n % 10; // 个位:123%10=3
return 0;
}
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
cout << n / 10 << endl; // ★ 十位:除以10
cout << n % 10; // ★ 个位:%10
return 0;
}
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
cout << n / 100 << endl; // ★ 百位
cout << n / 10 % 10 << endl; // ★ 十位
cout << n % 10; // ★ 个位
return 0;
}
#include <iostream>
using namespace std;
int main() {
int y, m, d;
cin >> y >> m >> d;
cout << y << "-" << m << "-" << d; // ★ 横杠写在引号里
return 0;
}
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
cout << "组数:" << n / 5 << endl;
cout << "剩余:" << n % 5;
return 0;
}