czj 1 rok pred
commit
55a89d3678

+ 17 - 0
VS Code/.vscode/c_cpp_properties.json

@@ -0,0 +1,17 @@
+{
+    "configurations": [
+        {
+            "name": "Win32",
+            "includePath": [
+                "${workspaceFolder}/**"
+            ],
+            "defines": [
+                "_DEBUG",
+                "UNICODE",
+                "_UNICODE"
+            ],
+            "intelliSenseMode": "msvc-x64"
+        }
+    ],
+    "version": 4
+}

+ 26 - 0
VS Code/.vscode/launch.json

@@ -0,0 +1,26 @@
+{  
+        "version": "0.2.0",  
+        "configurations": [  
+            {  
+                "name": "(gdb) Launch", // 配置名称,将会在启动配置的下拉菜单中显示  
+                "type": "cppdbg",       // 配置类型,这里只能为cppdbg  
+                "request": "launch",    // 请求配置类型,可以为launch(启动)或attach(附加)  
+                "program": "${workspaceFolder}/${fileBasenameNoExtension}.exe",// 将要进行调试的程序的路径  
+                "args": [],             // 程序调试时传递给程序的命令行参数,一般设为空即可  
+                "stopAtEntry": false,   // 设为true时程序将暂停在程序入口处,一般设置为false  
+                "cwd": "${workspaceFolder}", // 调试程序时的工作目录,一般为${workspaceFolder}即代码所在目录  
+                "environment": [],  
+                "externalConsole": true, // 调试时是否显示控制台窗口,一般设置为true显示控制台  
+                "MIMode": "gdb",  
+                "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe", // miDebugger的路径,注意这里要与MinGw的路径对应  
+                "preLaunchTask": "build++.exe g file", // 调试会话开始前执行的任务,一般为编译程序,c++为g++, c为gcc  
+                "setupCommands": [  
+                    {   
+                "description": "Enable pretty-printing for gdb",  
+                        "text": "-enable-pretty-printing",  
+                        "ignoreFailures": true  
+                    }  
+                ]  
+            }  
+        ]  
+    }

+ 7 - 0
VS Code/.vscode/settings.json

@@ -0,0 +1,7 @@
+{
+    "files.associations": {
+        "iostream": "cpp",
+        "*.tcc": "cpp",
+        "cmath": "cpp"
+    }
+}

+ 22 - 0
VS Code/.vscode/tasks.json

@@ -0,0 +1,22 @@
+{
+        "version": "2.0.0",
+        "tasks": [
+            {
+                "type": "shell",
+                "label": "build++.exe g file", //这里注意一下,见下文
+                "command": "C:\\MinGW\\bin\\g++.exe",
+                "args": [
+                    "-g",
+                    "${file}",
+                    "-o",
+                    "${fileDirname}\\${fileBasenameNoExtension}.exe"
+                ],
+                "options": {
+                    "cwd": "C:\\MinGW\\bin"
+                },
+                "problemMatcher": [
+                    "$gcc"
+                ]
+            }
+        ]
+    }

+ 18 - 0
VS Code/1.cpp

@@ -0,0 +1,18 @@
+#include <iostream>
+#include <math.h>
+using namespace std;
+int gcd(int a,int b){
+    int r=a%b;
+    while(r!=0){a=b;b=r;r=a%b;}
+    return b;
+}
+void reduction(int x1,int x2,int* add_y1,int* add_y2){int g=gcd(x1,x2);*add_y1=x1/g;*add_y2=x2/g;}
+int main()
+{
+    int a,b;
+    cin>>a>>b;
+    reduction(a,b,&a,&b);
+    cout<<a<<" "<<b;
+    system("pause");
+    return 0;
+}

BIN
VS Code/1.exe


+ 11 - 0
VS Code/2.cpp

@@ -0,0 +1,11 @@
+#include <bits/stdc++.h>
+using namespace std;
+int main(){
+    int e,f;
+    long long int d=1;
+    cin>>e>>f;
+    while((e*d)%f!=1){d++;}
+    cout<<d;
+    system("pause");
+    return 0;
+}

BIN
VS Code/2.exe


+ 15 - 0
VS Code/3.cpp

@@ -0,0 +1,15 @@
+#include <bits/stdc++.h>
+using namespace std;
+int encrypt(int m,int e,int n){int c=1;for(int i=0;i<e;i++){c=(c*m)%n;}return c;}
+int decode(int c,int d,int n){int m=1;for(int i=0;i<d;i++){m=(m*c)%n;}return m;}
+int m,c,e,n,d;
+int main (){
+    cin>>n>>e>>d;
+    cin>>m;
+    c=encrypt(m,e,n);
+    cout<<c<<endl;
+    m=decode(c,d,n);
+    cout<<m<<endl;
+    system("pause");
+    return 0;
+}

BIN
VS Code/3.exe


+ 28 - 0
VS Code/Fast Power.cpp

@@ -0,0 +1,28 @@
+#include <iostream>
+using namespace std;
+int main()
+{
+    int a;
+    long long int x,y;
+    y=1;
+    cin>>x>>a;
+    while(a!=1)
+    {
+        if(a%2==0)
+        {
+            x=x*x;
+            a=a/2;
+        }
+        else
+        {
+            y=y*x;
+            x=x*x;
+            a=(a-1)/2;
+        }
+        cout<<x<<" "<<a<<" "<<y<<endl;
+    }
+    x=x*y;
+    cout<<x<<endl;
+    system("pause");
+    return 0;
+}

BIN
VS Code/Fast Power.exe


+ 117 - 0
VS Code/fangcheng.cpp

@@ -0,0 +1,117 @@
+#include <iostream>
+#include <math.h>
+using namespace std;
+int main()
+{
+    double a,b,c,a2,a21,b1,x1,x2,gdelta,delta1,mum,den,mum1,den1;
+    int qu=1,delta,delta2;
+    cout<<"请输入a、b、c"<<endl;
+	cin>>a>>b>>c;//输入系数
+    cout<<a<<"x^2+"<<b<<"x+"<<c<<"=0"<<endl;
+	delta=delta1=(b*b)-(4*a*c); 
+    cout<<"delta="<<delta<<endl;
+    if (delta>=0&&(b*b)-(4*a*c)==floor((b*b)-(4*a*c)))//判断Δ是否>=0以及是否是整数
+    {
+        gdelta=sqrt(delta);
+        if (gdelta==floor(gdelta))//判断根号下Δ是否是整数
+        {
+            x1=(-b+gdelta)/(2*a);
+            x2=(-b-gdelta)/(2*a);
+            if (x1==floor(x1)&&x2==floor(x2))//判断解是不是整数
+            {
+                cout<<"x1="<<x1<<"\nx2="<<x2<<endl;
+            }
+            else
+            {
+                mum=-b+gdelta;
+                den=2*a;
+                for (int j = 2; j<=fabs(mum)&&j<=fabs(den); j++)
+                {
+                    mum1=mum/j;
+                    den1=den/j;
+                    if (mum1==floor(mum1)&&den1==floor(den1))
+                    {
+                        mum=mum1;den=den1;
+                        j=j-1;
+                    }
+                }
+                cout<<"x1="<<mum<<"/"<<den<<endl;
+                mum=-b-gdelta;
+                den=2*a;
+                for (int j = 2; j<=fabs(mum)&&j<=fabs(den); j++)
+                {
+                    mum1=mum/j;
+                    den1=den/j;
+                    if (mum1==floor(mum1)&&den1==floor(den1))
+                    {
+                        mum=mum1;den=den1;
+                        j=j-1;
+                    }
+                }
+                cout<<"x2="<<mum<<"/"<<den<<endl;
+            }
+        }
+        else
+        {
+            delta2=delta;
+            for(int i=2;i<=delta;i++)
+            {
+                int cnt=0;
+                while(delta!=i)
+                {
+                    if(delta%i==0)
+                    {
+                        cnt++;
+                        delta=delta/i;
+                        delta2=delta2/i;
+                    }
+                    else break;
+                }
+                if(i==delta)
+                {
+                    cnt++;
+                    delta=delta/i;
+                    delta2=delta2/i;
+                }
+                if(cnt!=0)
+                {
+                    if (cnt%2==0)
+                    {
+                        qu=qu*pow(i,cnt/2);
+                    }
+                    if (cnt%2!=0)
+                    {
+                        qu=qu*pow(i,(cnt-1)/2);
+                        delta2=delta2*i;
+                    }
+                }
+            }//开根号
+            a2=2*a;
+            for (int j = 2; j<=fabs(a2)&&j<=fabs(b)&&j<=fabs(qu); j++)
+            {
+                a21=a2/j;
+                b1=b/j;
+                if (qu%j==0&&b1==floor(b1)&&a21==floor(a21))
+                {
+                    qu=qu/j;a2=a21;b=b1;
+                    j=j-1;
+                }
+            }//化简
+            cout<<"x1=("<<-b<<"+"<<qu<<"*sqrt("<<delta2<<"))/"<<a2<<"\nx2=("<<-b<<"-"<<qu<<"*sqrt("<<delta2<<"))/"<<a2<<endl;
+        }
+    }
+    else if (delta>=0)
+    {
+        gdelta=sqrt(delta1);
+        cout<<"delta="<<delta1<<endl;
+        x1=(-b+gdelta)/(2*a);
+        x2=(-b-gdelta)/(2*a);
+        cout<<"x1="<<x1<<"\nx2="<<x2<<endl;
+    }//如果Δ是小数的话,暴力求解(本人技术有限)
+    else
+    {
+        cout<<"方程无实数根"<<endl;
+    }
+    system("pause");
+    return 0;
+}

BIN
VS Code/fangcheng.exe


+ 12 - 0
VS Code/g.cpp

@@ -0,0 +1,12 @@
+#include <iostream>
+#include <math.h>
+using namespace std;
+int main(){
+    double h,v,t;
+    cin>>h;
+    t=sqrt(h/4.9);
+    v=9.8*t;
+    cout<<v;
+    system("pause");
+    return 0;
+}

BIN
VS Code/g.exe


+ 12 - 0
VS Code/hanshu.cpp

@@ -0,0 +1,12 @@
+#include <iostream>
+#include <math.h>
+using namespace std;
+int main (){
+    double a,b,c,x,y;
+    cin>>a>>b>>c;
+    x=-b/(a*2);
+    y=((4*a*c)-b*b)/(4*a);
+    cout<<"("<<x<<","<<y<<")";
+    system("pause");
+    return 0;
+}

BIN
VS Code/hanshu.exe


+ 7 - 0
VS Code/hello world.cpp

@@ -0,0 +1,7 @@
+#include <iostream>
+int main()
+{
+    printf("Hello world\n");
+    system("pause");
+    return 0;
+}

BIN
VS Code/hello world.exe


+ 19 - 0
VS Code/rsa1.cpp

@@ -0,0 +1,19 @@
+#include <bits/stdc++.h>
+using namespace std;
+int encrypt(int m,int e,int n){int c=1;for(int i=0;i<e;i++){c=(c*m)%n;}return c;}
+char m[1024];
+int c[1024];
+int i,k,e,n;
+int main(){
+    cout<<"n:";
+    cin>>n;
+    cout<<"e:";
+    cin>>e;
+    cout<<"plaintext:";
+    cin>>m;
+    cout<<"cidhertext:"<<endl;
+    k=strlen(m);
+    for(i=0;i<k;i++){c[i]=m[i];c[i]=encrypt(c[i],e,n);cout<<c[i]<<" ";}
+    system("pause");
+    return 0;
+}

BIN
VS Code/rsa1.exe


+ 23 - 0
VS Code/rsa2.cpp

@@ -0,0 +1,23 @@
+#include <bits/stdc++.h>
+using namespace std;
+int decode(int c,int d,int n){int m=1;for(int i=0;i<d;i++){m=(m*c)%n;}return m;}
+char m[1024];
+int c[1024];
+int i,d,n;
+char a;
+int main(){
+    cout<<"n:";
+    cin>>n;
+    cout<<"d:";
+    cin>>d;
+    cout<<"cidhertext:";
+    while(scanf("%d",&c[i++])!=EOF)
+    {
+        a=cin.get();
+        if(a!=' ') break;
+    }
+    for(i=0;c[i]!=0;i++){m[i]=decode(c[i],d,n);}
+    cout<<m;
+    system("pause");
+    return 0;
+}

BIN
VS Code/rsa2.exe


+ 89 - 0
VS Code/sh.cpp

@@ -0,0 +1,89 @@
+#include <iostream>
+#include <math.h>
+using namespace std;
+int gcd(int a,int b){
+    int r=a%b;
+    while(r!=0){a=b;b=r;r=a%b;}
+    return b;
+}
+void reduction(int x1,int x2,int* add_y1,int* add_y2){int g=gcd(x1,x2);*add_y1=x1/g;*add_y2=x2/g;}
+int change(char a){
+    int b;
+    b=a-48;
+    return b;
+}
+int qpow(int a,int b){int ans=1;while(b){if(b&1)ans*=a;a*=a;b>>=1;}return ans;}
+char in[128];
+int i=1,j,k,a1=0,a2=0,b1=0,b2=0,c1=0,c2=0,z;
+bool m=true,n=false;
+int main (){
+    while(m==true){
+        cin>>in[i];
+        if(in[i]=='/'){n=true;j=i;}
+        if(in[i]==','){m=false;k=i;}
+        i++;
+    }
+    if(n==true){
+        for(i=j-1;i>0;i--){
+            a1=a1+change(in[i])*qpow(10,j-1-i);
+        }
+        for(i=k-1;i>j;i--){
+            a2=a2+change(in[i])*qpow(10,k-1-i);
+        }
+    }
+    else{
+        for(i=k-1;i>0;i--){
+            a1=a1+change(in[i])*qpow(10,k-1-i);
+        }
+        a2=1;
+    }
+    i=1;
+    m=true,n=false;
+    while(m==true){
+        cin>>in[i];
+        if(in[i]=='/'){n=true;j=i;}
+        if(in[i]==','){m=false;k=i;}
+        i++;
+    }
+     if(n==true){
+        for(i=j-1;i>0;i--){
+            b1=b1+change(in[i])*qpow(10,j-1-i);
+        }
+        for(i=k-1;i>j;i--){
+            b2=b2+change(in[i])*qpow(10,k-1-i);
+        }
+    }
+    else{
+        for(i=k-1;i>0;i--){
+            b1=b1+change(in[i])*qpow(10,k-1-i);
+        }
+        b2=1;
+    }
+    i=1;
+    m=true,n=false;
+    while(m==true){
+        cin>>in[i];
+        if(in[i]=='/'){n=true;j=i;}
+        if(in[i]==','){m=false;k=i;}
+        i++;
+    }
+     if(n==true){
+        for(i=j-1;i>0;i--){
+            c1=c1+change(in[i])*qpow(10,j-1-i);
+        }
+        for(i=k-1;i>j;i--){
+            c2=c2+change(in[i])*qpow(10,k-1-i);
+        }
+    }
+    else{
+        for(i=k-1;i>0;i--){
+            c1=c1+change(in[i])*qpow(10,k-1-i);
+            cout<<c1<<endl;
+        }
+        c2=1;
+    }
+    cout<<a1<<" "<<a2<<" "<<b1<<" "<<b2<<" "<<c1<<" "<<c2<<endl;
+    
+    system("pause");
+    return 0;
+}

BIN
VS Code/sh.exe


+ 75 - 0
VS Code/wuzi(1)(1).cpp

@@ -0,0 +1,75 @@
+#include<iostream>
+#include<math.h>
+using namespace std;
+char a[255];
+void say(){//没有返回值得改成void
+    cout<<"0123456789012345"<<endl;
+    for(int i=0;i<211;i=i+15){
+        cout<<(i/15+1)%10;
+        for(int j=i+1;j<i+16;j++){
+            cout<<a[j];
+        }
+        cout<<endl;
+    }
+}
+int x,y,k,m,n;
+bool judge(int b,char c,int l1,int r1,int l2,int r2){
+    for(int i=l1;i<r1;i++){
+        for(int j=l2;j<r2;j++){
+            k=j*15+i;
+            if(a[k]==c&&a[k+1*b]==c&&a[k+2*b]==c&&a[k+3*b]==c&&a[k+4*b]==c){
+                return true;
+                cout<<a[k]<<' '<<k<<' '<<b<<' '<<c<<endl;
+            }
+        }
+    }
+    return false;//不写这行很危险
+}
+bool work(char c,string side){
+    say();
+    if(judge(1,c,5,12,0,15)||judge(-1,c,5,12,0,15)){
+        cout<<side+" win!1"<<endl;
+        return false;
+    }
+    if(judge(15,c,1,16,4,11)||judge(-15,c,1,16,4,11)){
+        cout<<side+" win!2"<<endl;
+        return false;
+    }
+    if(judge(14,c,5,12,4,11)||judge(-14,c,5,12,4,11)||judge(16,c,5,12,4,11)||judge(-16,c,5,12,4,11)){
+        cout<<side+" win!3"<<endl;
+        return false;
+    }
+    return true;
+}
+int main(){
+    char c;
+    for(int i=0;i<226;i++){
+        a[i]=' ';
+    }
+    while(true){
+        cout<<"black:";
+        while(cin>>x>>y){
+            cout<<endl;
+            k=(y-1)*15+x;
+            if(a[k]==' '){
+                a[k]='X';
+                break;                
+            }
+            else cout<<"nope"<<endl;
+        }
+        if(!work('X',"black"))break;
+        cout<<"white:";
+        while(cin>>x>>y){
+            cout<<endl;
+            k=(y-1)*15+x;
+            if(a[k]==' '){
+                a[k]='O';
+                break;
+            }
+            else cout<<"nope"<<endl;
+        }
+        if(!work('O',"white"))break;
+    }
+    system("pause");
+    return 0;
+}

BIN
VS Code/wuzi(1)(1).exe


+ 171 - 0
VS Code/wuzi.cpp

@@ -0,0 +1,171 @@
+#include <iostream>
+#include <math.h>
+using namespace std;
+int say(char l[255])
+{
+    cout<<"0123456789012345"<<endl;
+    for (int i=0;i<211;i=i+15)
+    {
+        cout<<(i/15+1)%10;
+        for (int j=i+1;j<i+16;j++)
+        {
+            cout<<l[j];
+        }
+        cout<<endl;
+    }
+}
+int judge(char a[225],int k,int b,char c)
+{
+    if (a[k+1*b]==c&&a[k+2*b]==c&&a[k+3*b]==c&&a[k+4*b]==c)
+    {
+        return 1;
+        cout<<a[k]<<' '<<k<<' '<<b<<' '<<c<<endl;
+    }
+}
+int main () {
+    char a[255];
+    char c;
+    int x,y,k,m,n;
+    m=0;
+    for (int i = 0; i < 226; i++)
+    {
+        a[i]=' ';
+    }
+    while (m==0)
+    {
+        cout<<"blck:";
+        n=0;
+        while(n==0)
+        {
+            cin>>x>>y;
+            cout<<endl;
+            k=(y-1)*15+x;
+            if (a[k]==' ')
+            {
+                a[k]='X';
+                n=1;
+            }
+            else cout<<"nope"<<endl;
+        }
+        say(a);
+        c='X';
+        for (int i=5; i<12; i++)
+        {
+            for(int j=0 ; j<15; j++)
+            {
+                k=j*15+i;
+                if(a[k]==c)
+                {
+                    if(judge(a,k,1,c)==1||judge(a,k,-1,c)==1)
+                    {
+                        cout<<"black win!1"<<endl;
+                        m=1;
+                    }
+                }
+                
+            }
+        }
+        for (int i=1; i<16; i++)
+        {
+            for(int j=4 ; j<11; j++)
+            {
+                k=j*15+i;
+                if(a[k]==c)
+                {
+                    if(judge(a,k,15,c)==1||judge(a,k,-15,c)==1)
+                    {
+                        cout<<"black win!2"<<endl;
+                        m=1;
+                    }
+                }
+                
+            }
+        }
+        for (int i=5; i<12; i++)
+        {
+            for(int j=4 ; j<11; j++)
+            {
+                k=j*15+i;
+                if(a[k]==c)
+                {
+                    if(judge(a,k,14,c)==1||judge(a,k,-14,c)==1||judge(a,k,16,c)==1||judge(a,k,-16,c)==1)
+                    {
+                        cout<<"black win!3"<<endl;
+                        m=1;
+                    }
+                }
+                
+            }
+        }
+        if (m==1)
+        {
+            break;
+        }
+        cout<<"white:";
+        n=0;
+        while(n==0)
+        {
+            cin>>x>>y;
+            cout<<endl;
+            k=(y-1)*15+x;
+            if (a[k]==' ')
+            {
+                a[k]='O';
+                n=1;
+            }
+            else cout<<"nope"<<endl;
+        }
+        say(a);
+        c='O';
+        for (int i=5; i<12; i++)
+        {
+            for(int j=0 ; j<15; j++)
+            {
+                k=j*15+i;
+                if(a[k]==c)
+                {
+                    if(judge(a,k,1,c)==1||judge(a,k,-1,c)==1)
+                    {
+                        cout<<"white win!1"<<endl;
+                        m=1;
+                    }
+                }
+                
+            }
+        }
+        for (int i=1; i<16; i++)
+        {
+            for(int j=4 ; j<11; j++)
+            {
+                k=j*15+i;
+                if(a[k]==c)
+                {
+                    if(judge(a,k,15,c)==1||judge(a,k,-15,c)==1)
+                    {
+                        cout<<"white win!2"<<endl;
+                        m=1;
+                    }
+                }
+                
+            }
+        }
+        for (int i=5; i<12; i++)
+        {
+            for(int j=4 ; j<11; j++)
+            {
+                k=j*15+i;
+                if(a[k]==c)
+                {
+                    if(judge(a,k,14,c)==1||judge(a,k,-14,c)==1||judge(a,k,16,c)==1||judge(a,k,-16,c)==1)
+                    {
+                        cout<<"white win!3"<<endl;
+                        m=1;
+                    }
+                }
+                
+            }
+        }
+    }
+    system("pause");
+    return 0;
+}

BIN
VS Code/wuzi.exe


+ 1 - 0
VS Code/笔记.txt

@@ -0,0 +1 @@
+"dits/stdc++"

+ 42 - 0
sketch_jan17a.ino

@@ -0,0 +1,42 @@
+void setup() {
+  pinMode(2, OUTPUT);
+  pinMode(3, OUTPUT);
+  pinMode(4, OUTPUT);
+  pinMode(5, OUTPUT);
+  pinMode(6, INPUT);
+  // put your setup code here, to run once:
+
+}
+int i;
+bool a;
+void loop() {
+  digitalWrite(5, HIGH);
+
+  if(digitalRead(6)==HIGH&&a==false){
+    for(i=0;i<10;i++){
+      digitalWrite(2, HIGH);
+      delayMicroseconds(525);
+      digitalWrite(2, LOW);
+      delayMicroseconds(19475);
+    }
+    a=true;
+    digitalWrite(4, LOW);
+    digitalWrite(3, HIGH);
+  }
+  else if(digitalRead(6)==HIGH&&a==true){
+    for(i=0;i<10;i++){
+      digitalWrite(2, HIGH);
+      delayMicroseconds(900);
+      digitalWrite(2, LOW);
+      delayMicroseconds(19100);
+    }
+    a=false;
+    digitalWrite(4, LOW);
+    digitalWrite(3, HIGH);
+  }
+  else{
+    digitalWrite(4, LOW);
+    digitalWrite(3, LOW);
+  }
+  // put your main code here, to run repeatedly:
+}