Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6cfca39335 | |||
| 17ac063f22 | |||
| dbca0f836c | |||
| 8d012e9523 | |||
| 8633a4877f | |||
| e268fd03a2 | |||
| f5c717b856 | |||
| 9fdfe16b58 | |||
| 7aecf0da37 | |||
| 9e50890b5d | |||
| 7c42adee66 | |||
| dcbb90437b | |||
| 56b2815398 |
39
188.cpp
Normal file
39
188.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
int a[5];
|
||||
int max;
|
||||
bool bl=true;
|
||||
cout<<"请输入5个整数"<<endl;
|
||||
for(int i=0;i<5;i++)
|
||||
{
|
||||
cin>>a[i];
|
||||
}
|
||||
for(int i=0;i<5;i++)
|
||||
{
|
||||
for(int j=0;j<4-i;j++)
|
||||
{
|
||||
if(a[j]>a[j+1])
|
||||
{
|
||||
max=a[j];
|
||||
a[j]=a[j+1];
|
||||
a[j+1]=max;
|
||||
bl=false;
|
||||
}
|
||||
if(!bl)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
for(int n=0;n<5;n++) {
|
||||
|
||||
cout<<a[n]<<" ";
|
||||
|
||||
}
|
||||
}
|
||||
cout<<endl;
|
||||
|
||||
cout<<"阿哈哈哈啊哈哈哈哈,我我没有输出!!!"<<endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
45
20260321
45
20260321
@@ -1,45 +0,0 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
// 判断是否是素数
|
||||
bool isPrime(int n)
|
||||
{
|
||||
if (n < 2) return false;
|
||||
|
||||
for (int i = 2; i * i <= n; i++)
|
||||
{
|
||||
if (n % i == 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 判断是否是回文数
|
||||
bool isPalindrome(int n)
|
||||
{
|
||||
int original = n;
|
||||
int reversed = 0;
|
||||
|
||||
while (n > 0)
|
||||
{
|
||||
reversed = reversed * 10 + n % 10;
|
||||
n /= 10;
|
||||
}
|
||||
|
||||
return original == reversed;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
cout << "100到1000之间的回文素数有:" << endl;
|
||||
|
||||
for (int i = 100; i <= 1000; i++)
|
||||
{
|
||||
if (isPrime(i) && isPalindrome(i))
|
||||
{
|
||||
cout << i << " ";
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
//会场总共312人,第一排15人后一排比前一排多2人,求共有多少排,最后一排的人数。
|
||||
|
||||
1 #include<iostream>
|
||||
2 using namespace std;
|
||||
3
|
||||
4 int main(){
|
||||
5
|
||||
6 int p=1,x,sum;
|
||||
7 x=15;
|
||||
8 sum=x;
|
||||
9 while(sum<312){
|
||||
10 p+=1;
|
||||
11 x+=2;
|
||||
12 sum=sum+x;
|
||||
13
|
||||
14 cout<< "剧场有"<<p<<"排,"<<"最后一排有"<<x<<"人!"<<"共有"<<sum<<"人!"<<endl;
|
||||
15 }
|
||||
16
|
||||
17 return 0;
|
||||
18
|
||||
19 }
|
||||
@@ -21,17 +21,15 @@ int main() {
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 关键判断: 如果这一轮走完,swapped 还是 false,说明没有发生任何交换
|
||||
// 3. 关键判断:如果这一轮走完,swapped 还是 false,说明没有发生任何交换
|
||||
// 这意味着剩下的数字已经全都有序了,直接跳出循环
|
||||
if (!swapped) {
|
||||
cout<<"我没有运行 哈哈!";
|
||||
if (swapped == false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cout << "优化后的排序结果: ";
|
||||
for (int i = 0; i < n; i++)
|
||||
cout << a[i] << " ";
|
||||
for (int i = 0; i < n; i++) cout << a[i] << " ";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
int n;
|
||||
int a[n];
|
||||
cout<<"请输入数组的长度:"
|
||||
cin >> n;
|
||||
//给数组赋值;
|
||||
for (int i=0;i<n;i++)
|
||||
cin >> a[i];
|
||||
// 选择排序:给第 i 个位置找最合适的(最小的)数
|
||||
for (int i = 0; i < n - 1; i++) {
|
||||
int minidx = i; // 1. 先记下当前位置
|
||||
for (int j = i + 1; j < n; j++) {
|
||||
if (a[j] < a[minidx]) { // 2. 发现更小的了
|
||||
minidx = j; // 3. 只是记下它的位置,不交换
|
||||
}
|
||||
}
|
||||
swap(a[i], a[minidx]); // 4. 全看完后,只换这一次
|
||||
}
|
||||
//输出已排好的队伍
|
||||
for(int i=0;i<n;i++)
|
||||
cout<<a[i]<<" ";
|
||||
cout<<endl;
|
||||
return 0;
|
||||
}
|
||||
20
260314/03.cpp
Normal file
20
260314/03.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
|
||||
for(int i=2;i<100;i++){
|
||||
bool n=true;
|
||||
|
||||
for(int j=2;j*j<=i;j++){
|
||||
|
||||
if(i%j==0){
|
||||
n=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(n)
|
||||
cout<<i<<" ";
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
20
260314/100以内的素数.cpp
Normal file
20
260314/100以内的素数.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
|
||||
for(int i=2;i<100;i++){
|
||||
bool n=true;
|
||||
|
||||
for(int j=2;j*j<=i;j++){
|
||||
|
||||
if(i%j==0){
|
||||
n=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(n)
|
||||
cout<<i<<" ";
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
20
260314/两数交换指针.cpp
Normal file
20
260314/两数交换指针.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include<iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
int * ptr_a,* ptr_b;
|
||||
ptr_a = new int;
|
||||
ptr_b = new int;
|
||||
int temp;
|
||||
|
||||
cin>>*ptr_a>>*ptr_b;
|
||||
temp=*ptr_a;
|
||||
*ptr_a=*ptr_b;
|
||||
*ptr_b=temp;
|
||||
cout<<*ptr_a<<" "<<*ptr_b<<endl;
|
||||
delete ptr_a,ptr_b;
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
18
260314/最大值指针.cpp
Normal file
18
260314/最大值指针.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
int a[10]={1,200,315,4,5,6,71,8,9,10};
|
||||
int *b=a;
|
||||
|
||||
for(int i=1;i<10;i++)
|
||||
if(*b<a[i])
|
||||
*b=a[i];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cout<<*b<<endl;
|
||||
return 0;
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
for (int n = 2; n <= 100; n++) {
|
||||
bool x = true;
|
||||
// i*i <=n因数是成对出现的任何一个合数 ,都可以写成两个数相乘:
|
||||
//n = a * b
|
||||
//比如 n = 16,它的因数对有:
|
||||
//2 * 8 = 16
|
||||
//4 * 4 = 16
|
||||
//8 * 2 = 16
|
||||
|
||||
for (int i = 2; i * i <= n; i++) {
|
||||
if (n % i == 0) {
|
||||
x = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (x) {
|
||||
cout << n << " ";
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
18
666/02.2.0.cpp
Normal file
18
666/02.2.0.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
void bjdx(int a,int b){
|
||||
|
||||
|
||||
if(a>b)
|
||||
|
||||
cout<<a<<"大大大大大大大大大大大大大大大大大大大大大大大大大"<<endl;
|
||||
else
|
||||
|
||||
cout<<b<<"大大大大大大大大大大大大大大大大大大大大大大大大大"<<endl;
|
||||
}
|
||||
int main(){
|
||||
int a,b;
|
||||
cin>>a>>b;
|
||||
bjdx(a,b);
|
||||
return 0;
|
||||
}
|
||||
BIN
666/02.2.1
Normal file
BIN
666/02.2.1
Normal file
Binary file not shown.
16
666/02.2.2.cpp
Normal file
16
666/02.2.2.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int bjdx(int a){
|
||||
int b=1;
|
||||
for(int i=1;i<=a;i++)
|
||||
b=b*i;
|
||||
|
||||
return b;
|
||||
}
|
||||
int main(){
|
||||
int pdd;
|
||||
cin>>pdd;
|
||||
cout<<bjdx(pdd)<<endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
12
666/02.cpp
Normal file
12
666/02.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
int a,b;
|
||||
cin>>a>>b;
|
||||
if(a>b)
|
||||
cout<<a<<"大大大大大大大大大大大大大大大大大大大大大大大大大"<<endl;
|
||||
else;
|
||||
cout<<b<<"大大大大大大大大大大大大大大大大大大大大大大大大大"<<endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
20
666/nd.cpp
Normal file
20
666/nd.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include<iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
int * ptr_a,* ptr_b;
|
||||
ptr_a = new int;
|
||||
ptr_b = new int;
|
||||
int temp;
|
||||
|
||||
cin>>*ptr_a>>*ptr_b;
|
||||
temp=*ptr_a;
|
||||
*ptr_a=*ptr_b;
|
||||
*ptr_b=temp;
|
||||
cout<<*ptr_a<<" "<<*ptr_b<<endl;
|
||||
delete ptr_a,ptr_b;
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
13
666/交换.cpp
Normal file
13
666/交换.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
|
||||
int a,b,c;
|
||||
cin>>a>>b;
|
||||
cout<<a<<" "<<b<<" ";
|
||||
c=a;
|
||||
a=b;
|
||||
b=c;
|
||||
cout<<a<<" "<<b<<endl;
|
||||
return 0;
|
||||
}
|
||||
13
666/交换2.cpp
Normal file
13
666/交换2.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
|
||||
int a,b,c;
|
||||
cin>>a>>b;
|
||||
cout<<a<<" "<<b<<" ";
|
||||
c=a;
|
||||
a=b;
|
||||
b=c;
|
||||
cout<<a<<" "<<b<<endl;
|
||||
return 0;
|
||||
}
|
||||
18
666/交换3.cpp
Normal file
18
666/交换3.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
|
||||
int a=25,b=32,tmp;
|
||||
int *ptr_a, *ptr_b;
|
||||
|
||||
ptr_a=&a;
|
||||
ptr_b=&b;
|
||||
|
||||
cout<<*ptr_a<<" "<<*ptr_b<<" ";
|
||||
cout<<ptr_a<<" "<<ptr_b<<" ";
|
||||
tmp=*ptr_a;
|
||||
*ptr_a=*ptr_b;
|
||||
*ptr_b=tmp;
|
||||
cout<<a<<" "<<b<<endl;
|
||||
return 0;
|
||||
}
|
||||
24
666/最大值2.cpp
Normal file
24
666/最大值2.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
int a[5]={87,99,3,12,1};
|
||||
int max=a[0];
|
||||
int * ptr_x;
|
||||
ptr_x=a;
|
||||
|
||||
|
||||
for(int i=1;i<5;i++){
|
||||
|
||||
if(*ptr_x > max){
|
||||
max = *ptr_x;
|
||||
}
|
||||
ptr_x++;
|
||||
cout<<ptr_x<<endl;
|
||||
|
||||
}
|
||||
|
||||
cout<<max<<" ";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
17
666/最大值3.cpp
Normal file
17
666/最大值3.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
int a[5]={9,99,999,9999,99999};
|
||||
int *ptr_x;
|
||||
int max;
|
||||
ptr_x=a;
|
||||
max=*ptr_x;
|
||||
for(int i=1;i<=5;i++){
|
||||
if(*ptr_x>max)
|
||||
max=*ptr_x;
|
||||
ptr_x++;
|
||||
}
|
||||
cout<<max<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
16
918.cpp
Normal file
16
918.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
|
||||
int i=15,p=1,sum=i;
|
||||
while(sum<312){
|
||||
p++;
|
||||
sum=sum+i;
|
||||
i=i+2;
|
||||
}
|
||||
cout<<p<<" "<<i<<endl;
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
26
config.yaml
26
config.yaml
@@ -1,26 +0,0 @@
|
||||
server_url: https://hs.yihaoai.cc
|
||||
listen_addr: 0.0.0.0:8080
|
||||
metrics_listen_addr: 127.0.0.1:9090
|
||||
grpc_listen_addr: 0.0.0.0:50443
|
||||
grpc_allow_insecure: false
|
||||
noise:
|
||||
private_key_path: /var/lib/headscale/noise_private.key
|
||||
prefixes:
|
||||
v4: 100.64.0.0/10
|
||||
v6: fd7a:115c:a1e0::/48
|
||||
derp:
|
||||
server:
|
||||
enabled: false
|
||||
urls:
|
||||
- https://controlplane.tailscale.com/derpmap/default
|
||||
database:
|
||||
type: sqlite3
|
||||
sqlite:
|
||||
path: /var/lib/headscale/db.sqlite
|
||||
dns:
|
||||
magic_dns: true
|
||||
base_domain: yihaoai.local
|
||||
nameservers:
|
||||
global:
|
||||
- 114.114.114.114
|
||||
- 8.8.8.8
|
||||
16
指针/交换值 .cpp
16
指针/交换值 .cpp
@@ -1,16 +0,0 @@
|
||||
1 #include<iostream>
|
||||
2 using namespace std;
|
||||
3
|
||||
4 int main(){
|
||||
5 int a=10,b=5,temp,*ptr_a,*ptr_b;
|
||||
6 cout<<"a的值是:"<<a<<" b的值是:"<<b<<endl;
|
||||
7 ptr_a=&a;
|
||||
8 ptr_b=&b;
|
||||
9 temp=*ptr_a;
|
||||
10 *ptr_a=*ptr_b;
|
||||
11 *ptr_b=temp;
|
||||
12
|
||||
13 cout<<"交换后a的值是:"<<a<<" b的值是:"<<b<<endl;
|
||||
14
|
||||
15 return 0;
|
||||
16 }
|
||||
@@ -1,20 +0,0 @@
|
||||
1 #include<iostream>
|
||||
2 using namespace std;
|
||||
3
|
||||
4 int main(){
|
||||
5
|
||||
6 int a=10;
|
||||
7 int b[5]={10,20,30,40,50};
|
||||
8 int * ptr_a , * ptr_b;
|
||||
9
|
||||
10 ptr_a=&a;
|
||||
11 ptr_b=b;
|
||||
12 cout << "我是内存地址: "<<ptr_a <<" 我是地址内的值 : "<< * ptr_a<<endl;
|
||||
13 cout << "我是内存地址: "<<ptr_b <<" 我是地址内的值 : "<< * ptr_b<<endl;
|
||||
14
|
||||
15 for (int i=0;i<5;i++)
|
||||
16 cout << "我的地址:"<< ptr_b+i<<endl;
|
||||
17
|
||||
18 return 0;//这个可以省略
|
||||
19
|
||||
20 }
|
||||
14
指针/指针地址.cpp
14
指针/指针地址.cpp
@@ -1,14 +0,0 @@
|
||||
1 #include<iostream>
|
||||
2 using namespace std;
|
||||
3
|
||||
4 int main(){
|
||||
5
|
||||
6 int a=10;
|
||||
7 int * ptr_a ;
|
||||
8
|
||||
9 ptr_a=&a;
|
||||
10 cout << "我是内存地址: "<<ptr_a <<" 我是地址内的值 : "<< * ptr_a<<endl;
|
||||
11
|
||||
12 return 0;//这个可以省略
|
||||
13
|
||||
14 }
|
||||
19
指针/求最大值 .cpp
19
指针/求最大值 .cpp
@@ -1,19 +0,0 @@
|
||||
1 #include<iostream>
|
||||
2 using namespace std;
|
||||
3
|
||||
4 int main(){
|
||||
5 int max,*ptr;
|
||||
6 int arr[5]={10,20,33,15,11};
|
||||
7 max = arr[0];
|
||||
8 ptr = arr;
|
||||
9
|
||||
10 for (int i = 0; i < 5; i++) {
|
||||
11 if (*ptr > max) {
|
||||
12 max = *ptr;
|
||||
13 }
|
||||
14 ptr++;
|
||||
15 }
|
||||
16 cout << "最大值是:"<< max<<endl;
|
||||
17
|
||||
18 return 0;
|
||||
19 }
|
||||
@@ -1,39 +0,0 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
struct Harem
|
||||
{
|
||||
int id;
|
||||
int age;
|
||||
string name;
|
||||
};
|
||||
|
||||
void show(const Harem &hm) // ⭐ 类型必须写
|
||||
{
|
||||
cout <<" " <<hm.id <<" "<< hm.age <<" "<< hm.name << endl;
|
||||
// cout << "ID:" << hm.id
|
||||
// << " AGE: " << hm.age
|
||||
// << " NAME: " << hm.name
|
||||
// << endl;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
Harem people[] =
|
||||
{
|
||||
{1001, 18, "佐伊"},
|
||||
{1002, 19, "寒冰"},
|
||||
{1003, 17, "女警"},
|
||||
{1004, 18, "盖伦"}
|
||||
};
|
||||
|
||||
int size = sizeof(people) / sizeof(people[0]);
|
||||
|
||||
for (int i = 0 ; i< size ; i++ )
|
||||
{
|
||||
show(people[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user