'commit'
This commit is contained in:
16
C++课程/习题训练/3N+1问题_1.cpp
Normal file
16
C++课程/习题训练/3N+1问题_1.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int n, count = 0;
|
||||
scanf("%d", &n);
|
||||
while(n > 1)
|
||||
{
|
||||
if(n%2 == 1) n = n * 3 + 1;
|
||||
else n /= 2;
|
||||
count++;
|
||||
}
|
||||
printf("%d\n", count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
18
C++课程/习题训练/3N+1问题_2.cpp
Normal file
18
C++课程/习题训练/3N+1问题_2.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int count = 0;
|
||||
long long n;//<2F><><EFBFBD><EFBFBD>64λ<34><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
scanf("%lld", &n);//<2F>˴<EFBFBD>"%lld"Ҳ<><D2B2>д<EFBFBD><D0B4>"%I64d"
|
||||
while(n > 1)
|
||||
{
|
||||
if(n%2 == 1) n = n * 3 + 1;
|
||||
else n /= 2;
|
||||
count++;
|
||||
}
|
||||
printf("%d\n", count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
18
C++课程/习题训练/7744问题_1.cpp
Normal file
18
C++课程/习题训练/7744问题_1.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int a, b, n;
|
||||
double m;
|
||||
for(a = 1; a <= 9; a++)
|
||||
{
|
||||
for(b = 0; b <= 9; b++)
|
||||
{
|
||||
n = 1100*a + 11*b;
|
||||
m = sqrt(n);
|
||||
if(floor(m+0.5) == m) printf("(1):%d\n", n);//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ȣ<EFBFBD>floor<6F><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>m<EFBFBD><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD><D6A3><EFBFBD><EFBFBD><EFBFBD>0.5<EFBFBD><EFBFBD>Ϊ<EFBFBD>˼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD>졣
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
17
C++课程/习题训练/7744问题_2.cpp
Normal file
17
C++课程/习题训练/7744问题_2.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int a, b, x, n;
|
||||
for(x = 32; ; x++)
|
||||
{
|
||||
n = x * x;
|
||||
if(n > 9999) break;
|
||||
a = n / 100;
|
||||
b = n % 100;
|
||||
if(a/10 == a%10 && b/10 == b%10) printf("(2):%d\n", n);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BIN
C++课程/习题训练/C++语言每日小练一3N+1问题.pptx
Normal file
BIN
C++课程/习题训练/C++语言每日小练一3N+1问题.pptx
Normal file
Binary file not shown.
BIN
C++课程/习题训练/C++语言每日小练一7744问题.pptx
Normal file
BIN
C++课程/习题训练/C++语言每日小练一7744问题.pptx
Normal file
Binary file not shown.
BIN
C++课程/习题训练/C++语言每日小练一n!问题.pptx
Normal file
BIN
C++课程/习题训练/C++语言每日小练一n!问题.pptx
Normal file
Binary file not shown.
BIN
C++课程/习题训练/C++语言每日小练一开灯问题.pptx
Normal file
BIN
C++课程/习题训练/C++语言每日小练一开灯问题.pptx
Normal file
Binary file not shown.
BIN
C++课程/习题训练/C++语言每日小练一竖式问题.pptx
Normal file
BIN
C++课程/习题训练/C++语言每日小练一竖式问题.pptx
Normal file
Binary file not shown.
BIN
C++课程/习题训练/C++语言每日小练一蛇形填数.pptx
Normal file
BIN
C++课程/习题训练/C++语言每日小练一蛇形填数.pptx
Normal file
Binary file not shown.
18
C++课程/习题训练/N!问题_1.cpp
Normal file
18
C++课程/习题训练/N!问题_1.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
#define MOD 1000000
|
||||
int main()
|
||||
{
|
||||
int i, j, n, m, S = 0;
|
||||
scanf("%d", &n);
|
||||
for(i = 1; i <= n; i++)
|
||||
{
|
||||
m = 1;
|
||||
for(j = 1; j <= i; j++) m = (m*j) % MOD;
|
||||
S = (S+m) % MOD;
|
||||
}
|
||||
printf("%d\n", S);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
15
C++课程/习题训练/N!问题_2.cpp
Normal file
15
C++课程/习题训练/N!问题_2.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
const int MOD = 1000000;
|
||||
int i, n;
|
||||
long long S = 0;
|
||||
scanf("%d", &n);
|
||||
for( i = n; i >= 1; i-- )
|
||||
S = (S + 1) * i % MOD;
|
||||
printf("%lld\n", S);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
16
C++课程/习题训练/N!问题_3.cpp
Normal file
16
C++课程/习题训练/N!问题_3.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
const int MOD = 1000000;
|
||||
int i, n;
|
||||
int S = 0;
|
||||
scanf("%d", &n);
|
||||
if(n > 25) n = 25;
|
||||
for( i = n; i >= 1; i-- )
|
||||
S = (S + 1) * i % MOD;
|
||||
printf("%d\n", S);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
21
C++课程/习题训练/开灯问题.cpp
Normal file
21
C++课程/习题训练/开灯问题.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
#define MAX 1000+10
|
||||
int a[MAX];
|
||||
int main()
|
||||
{
|
||||
int i, j, n, k;
|
||||
memset(a, 0, sizeof(a));
|
||||
scanf("%d%d", &n, &k);
|
||||
for(i = 1; i <= k; i++)
|
||||
for(j = 1; j <= n; j++)
|
||||
if(j%i == 0) a[j] = !a[j];
|
||||
for(i = 1; i <= n; i++) if(a[i])
|
||||
{
|
||||
if(i == n) printf("%d\n", i);
|
||||
else printf("%d ", i);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
1
C++课程/习题训练/相关学习网站.txt
Normal file
1
C++课程/习题训练/相关学习网站.txt
Normal file
@@ -0,0 +1 @@
|
||||
https://blog.csdn.net/zenail501129/article/list/3?t=1&
|
||||
27
C++课程/习题训练/竖式问题.cpp
Normal file
27
C++课程/习题训练/竖式问题.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int i, ok, abc, de, x, y, z, count = 0;
|
||||
char s[11], buf[50];
|
||||
scanf("%s", s);
|
||||
for(abc = 111; abc <= 999; abc++)
|
||||
for(de = 11; de <= 99; de++)
|
||||
{
|
||||
x = abc*(de%10); y = abc*(de/10); z = abc*de;
|
||||
sprintf(buf, "%d%d%d%d%d", abc, de, x, y, z);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>뻺<EFBFBD><EBBBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
ok = 1;
|
||||
for(i = 0; i<strlen(buf) && ok==1; i++)
|
||||
if(strchr(s, buf[i]) == NULL) ok = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿһ<C3BF><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>бȽϣ<C8BD><CFA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>strchr<68><72><EFBFBD><EFBFBD>NULL<4C><4C>
|
||||
if(ok)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
23
C++课程/习题训练/蛇形填数.cpp
Normal file
23
C++课程/习题训练/蛇形填数.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int a[10][10];
|
||||
int main() {
|
||||
int i, j, n, count;
|
||||
memset(a, 0, sizeof(a));
|
||||
scanf("%d", &n);
|
||||
count = a[i = 1][j = n] = 1;//<2F><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>-><3E><>
|
||||
while(count < n*n) {
|
||||
while(i<n && !a[i+1][j]) a[++i][j] = ++count;//<2F><>
|
||||
while(j>1 && !a[i][j-1]) a[i][--j] = ++count;//<2F><>
|
||||
while(i>1 && !a[i-1][j]) a[--i][j] = ++count;//<2F><>
|
||||
while(j<n && !a[i][j+1]) a[i][++j] = ++count;//<2F><>
|
||||
}
|
||||
for(i = 1; i <= n; i++)
|
||||
for(j = 1; j <= n; j++) {
|
||||
if(j == n) printf("%3d\n", a[i][j]);
|
||||
else printf("%3d", a[i][j]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user