homework in 12.6
This commit is contained in:
parent
381be4fba1
commit
07320d68ef
16
homework_1.cpp
Normal file
16
homework_1.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n; // 输入一个正整数n
|
||||
long long result = 1; // 使用long long类型来避免结果溢出
|
||||
|
||||
// 计算阶乘
|
||||
for (int i = 1; i <= n; ++i) {
|
||||
result *= i;
|
||||
}
|
||||
|
||||
cout << result << endl; // 输出阶乘的结果
|
||||
return 0;
|
||||
}
|
12
homework_2.cpp
Normal file
12
homework_2.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int peaches = 1; // 第10天剩下的桃子数
|
||||
// 逆推从第10天到第1天
|
||||
for (int day = 9; day >= 1; --day) {
|
||||
peaches = (peaches + 1) * 2; // 每天的桃子数量是前一天的剩余加1再乘2
|
||||
}
|
||||
cout << "第1天摘的桃子数量是: " << peaches << endl;
|
||||
return 0;
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
#include<iostream> //字母位移
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*
|
||||
int main(){
|
||||
char CIN,COUT;
|
||||
|
||||
cin >> CIN;
|
||||
|
||||
int CIN2 = CIN+=3;
|
||||
|
||||
COUT = CIN2;
|
||||
|
||||
cout <<COUT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main(){
|
||||
while (true)
|
||||
{
|
||||
char letter;
|
||||
int n = 3;
|
||||
|
||||
cin >>letter;
|
||||
|
||||
if (letter >= 'A' && letter <= 'Z') {
|
||||
char new_letter = (letter - 'A' + n) % 26 + 'A';
|
||||
cout << new_letter<<endl;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
int main(){
|
||||
while (true)
|
||||
{
|
||||
char ch1,ch2;
|
||||
|
||||
int n = 3;
|
||||
|
||||
cin >>ch1;
|
||||
ch2 = ((ch1 -65)+n) %26 +65;
|
||||
|
||||
cout <<ch2<<endl;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
Binary file not shown.
@ -1,52 +0,0 @@
|
||||
#include<iostream> //字母位移
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*
|
||||
int main(){
|
||||
char CIN,COUT;
|
||||
|
||||
cin >> CIN;
|
||||
|
||||
int CIN2 = CIN+=3;
|
||||
|
||||
COUT = CIN2;
|
||||
|
||||
cout <<COUT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main(){
|
||||
while (true)
|
||||
{
|
||||
char letter;
|
||||
int n = 3;
|
||||
|
||||
cin >>letter;
|
||||
|
||||
if (letter >= 'A' && letter <= 'Z') {
|
||||
char new_letter = (letter - 'A' + n) % 26 + 'A';
|
||||
cout << new_letter<<endl;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
int main(){
|
||||
while (true)
|
||||
{
|
||||
char ch1,ch2;
|
||||
|
||||
int n = 3;
|
||||
|
||||
cin >>ch1;
|
||||
ch2 = ((ch1 -65)+n) %26 +65;
|
||||
|
||||
cout <<ch2<<endl;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user