'commit'
This commit is contained in:
19
RuMenJingDian/LianXi/C_1_13.cpp
Normal file
19
RuMenJingDian/LianXi/C_1_13.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false); //读入输出优化的强迫症
|
||||
int a[3];
|
||||
cin >> a[0] >> a[1] >> a[2];
|
||||
//快排
|
||||
// sort(a, a + 3, greater<int>()); //降序
|
||||
sort(a, a + 3, less<int>()); //升序
|
||||
|
||||
//输出数组
|
||||
for (int i = 0; i < 3; i++) {
|
||||
cout << a[i]<<" ";
|
||||
}
|
||||
cout << endl;
|
||||
return 0;
|
||||
}
|
||||
15
RuMenJingDian/LianXi/C_1_15.cpp
Normal file
15
RuMenJingDian/LianXi/C_1_15.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false); //读入输出优化的强迫症
|
||||
int a, b, c;
|
||||
cin >> a >> b >> c;
|
||||
int d = a + b + c;
|
||||
float e = d * 1.0 / 3;
|
||||
//设置输出为小数点后3位
|
||||
cout << fixed << setprecision(3);
|
||||
cout << e << endl;
|
||||
return 0;
|
||||
}
|
||||
14
RuMenJingDian/LianXi/C_1_2.cpp
Normal file
14
RuMenJingDian/LianXi/C_1_2.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false); //读入输出优化的强迫症
|
||||
printf("%.1f\n", 8.0 / 5.0); //保留一位小数
|
||||
printf("%.2f\n", 8.0 / 5.0); //保留两位小数
|
||||
|
||||
printf("%.1f\n", 8 / 5); //实验6
|
||||
printf("%d\n", 8.0 / 5.0); //实验7
|
||||
|
||||
return 0;
|
||||
}
|
||||
17
RuMenJingDian/LianXi/C_1_7.cpp
Normal file
17
RuMenJingDian/LianXi/C_1_7.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false); //读入输出优化的强迫症
|
||||
int n;
|
||||
cin >> n;
|
||||
//求3位数的反转
|
||||
int gewei = n % 10; //个位
|
||||
int shiwei = n / 10 % 10; //十位
|
||||
int baiwei = n / 100; //百位
|
||||
cout << gewei << shiwei << baiwei << endl;
|
||||
//补0输出3位数
|
||||
printf("%03d",25); //结果为025,果然神奇!
|
||||
return 0;
|
||||
}
|
||||
13
RuMenJingDian/LianXi/C_3_1.cpp
Normal file
13
RuMenJingDian/LianXi/C_3_1.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
#define maxn 105
|
||||
int a[maxn];
|
||||
|
||||
int main() {
|
||||
int x, n = 0;
|
||||
while (scanf("%d", &x) == 1) a[n++] = x; //以ctrl+d结束输入
|
||||
for (int i = n - 1; i >= 1; i--) printf("%d ", a[i]);
|
||||
printf("%d\n", a[0]);
|
||||
return 0;
|
||||
}
|
||||
25
RuMenJingDian/LianXi/C_3_2.cpp
Normal file
25
RuMenJingDian/LianXi/C_3_2.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define maxn 1010
|
||||
int a[maxn];
|
||||
|
||||
int main() {
|
||||
int n, k, first = 1;
|
||||
//初始化数组
|
||||
memset(a, 0, sizeof(a));
|
||||
//用户输入
|
||||
scanf("%d%d", &n, &k);
|
||||
|
||||
for (int i = 1; i <= k; i++)
|
||||
for (int j = 1; j <= n; j++)
|
||||
if (j % i == 0) a[j] = !a[j];
|
||||
for (int i = 1; i <= n; i++)
|
||||
if (a[i]) {
|
||||
if (first) first = 0; else printf(" ");
|
||||
printf("%d", i);
|
||||
}
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
27
RuMenJingDian/LianXi/C_3_3.cpp
Normal file
27
RuMenJingDian/LianXi/C_3_3.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define maxn 20
|
||||
int a[maxn][maxn];
|
||||
//蛇型填数
|
||||
int main()
|
||||
{
|
||||
int n, x, y, tot = 0;
|
||||
scanf("%d", &n);
|
||||
memset(a, 0, sizeof(a));
|
||||
tot = a[x = 0][y = n - 1] = 1;
|
||||
while (tot < n * n)
|
||||
{
|
||||
while (x + 1 < n && !a[x + 1][y]) a[++x][y] = ++tot;
|
||||
while (y - 1 >= 0 && !a[x][y - 1]) a[x][--y] = ++tot;
|
||||
while (x - 1 >= 0 && !a[x - 1][y]) a[--x][y] = ++tot;
|
||||
while (y + 1 < n && !a[x][y + 1]) a[x][++y] = ++tot;
|
||||
}
|
||||
for (x = 0; x < n; x++)
|
||||
{
|
||||
for (y = 0; y < n; y++) printf("%3d", a[x][y]);
|
||||
printf("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
23
RuMenJingDian/LianXi/C_3_4.cpp
Normal file
23
RuMenJingDian/LianXi/C_3_4.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int count = 0;
|
||||
char s[20], buf[99];
|
||||
scanf("%s", s);
|
||||
for (int abc = 111; abc <= 999; abc++)
|
||||
for (int de = 11; de <= 99; de++) {
|
||||
int x = abc * (de % 10), y = abc * (de / 10), z = abc * de;
|
||||
sprintf(buf, "%d%d%d%d%d", abc, de, x, y, z);
|
||||
int ok = 1;
|
||||
for (int i = 0; i < strlen(buf); i++)
|
||||
if (strchr(s, buf[i]) == NULL) ok = 0;
|
||||
if (ok) {
|
||||
printf("<%d>\n", ++count);
|
||||
printf("%5d\nX%4d\n-----\n%5d\n%4d\n-----\n%5d\n\n", abc, de, x, y, z);
|
||||
}
|
||||
}
|
||||
printf("The number of solutions = %d\n", count);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user