关于linux上运行ONS

https://tieba.baidu.com/p/5202079866?pv=1 用ONScripter 安装依赖库 sudo apt-get install libsdl1.2debian libsdl-sound1.2 libsdl-ttf2.0-0 libsdl-mixer1.2 libsdl-image1.2 libasound2 libjpeg62 libpng12-0 libvorbisfile3 libsmpeg0 libavifile-0.7c2 libbz2-1.0 libogg0

SuCicada

关于ssh scp 不用交互式 即自动或者带密码执行

sshpass方式 expect方式 第一种方式 通过 sshpass 来 sshpass -p "xxxx" ssh root@xxx.xx.xxx sshpass -p "xxxx" scp xxxx root@xxxx:/xxxxx 但是sshpass好像不能回显. 对于scp不太方便 但是对于ssh确实很好用的 第二种方式 通过expect 用法参考 比如使用ssh #!/usr/bin/expect set timeout 30 spawn ssh root@sucicada.tk expect "password:" send "Ubuntu2019\n" interact 通过以上方式可以使用一个脚本就能登录到远程主机上了

SuCicada

关于辗转相除

#include<iostream> using namespace std; int gcd(int a,int b,int& x,int &y){ if(b==0){ x = 1; y = 0; return a; } int q = gcd(b, a%b, y, x); // y 是给b用的 // a 是大的那个 y = (q-a*x)/b; cout<<a<<" "<<b<<" "<<x<<" "<<y<<endl; return q; } int main(){ int x,y; int a=12; int b=32; gcd(a,b,x,y); } 这就是我这个菜鸡的代码备份,草我特么咋就这么笨

SuCicada

关于阿里云的一些配置:

先apt update 更新 作为 安装 nginx 反向代理服务器

SuCicada

刘汝佳p35,2-5(分数化小数)算法竞赛入门经典第二版

输入a,b,c,输出a/b的小数形式,精确到小数点后c位,a,b<=10^6,c<=100,以a=b=c=0结束,四舍五入 #include<stdio.h> int main() { int a,b,c,n=1; while(scanf("%d%d%d",&a,&b,&c)&&(a||b||c)) { printf("Case %d: %d.",n++,a/b);//整数位和小数点 for(int i=0;i<c-1;i++) { printf("%d",(a*10/b)%10); a=(a*10)%b;//为了不让a溢出,用a/b的余数来算并不影响结果 } printf("%d\n",((a*100/b)%100+5)/10);//最后一位四舍五入 } return 0; } 已经连这种简单的算法都要上网看别人写的了,自己想出来的都是错的,浪费了一个小时又。

SuCicada

刘汝佳p35,2-6(123排列)算法竞赛入门经典第二版

算法竞赛入门经典第二版 刘汝佳p35 , 2-6 用1,2,3,….,9组成3个三位数abc,def和ghi,每个数字恰好使用一次,要求abc:def:ghi=1:2:3。输出所有解。 #include<cstdio> #include<iostream> using namespace std; int nn(int a,int *n) { //cout<<"a"<<a<<endl; for(int i=0;i<8;i++) { if(a==n[i]) { //cout<<n[i]<<endl; n[i]=-1; return 0; } } return 1; } void num(int a) { int n[9]; for(int i=0;i<8;i++) n[i]=i+1; int b=a*2; int c=a*3; int s[9]; s[0]=a/100; s[1]=(a/10)%10; s[2]=a%10; s[3]=b/100; s[4]=(b/10)%10; s[5]=b%10; s[6]=c/100; s[7]=(c/10)%10; s[8]=c%10; for(int i=0;i<8;i++) { //cout<<"si"<<s[i]<<endl; if(nn(s[i],n)==1) { //cout<<"return"<<endl; return; } } cout<<a<<" "<<b<<" "<<c<<endl; } int main() { for(int a=100;a<=333;a++) { num(a); } return 0; } 所以结果是...

SuCicada

刘汝佳p39,3-2(开灯问题)算法竞赛入门经典第二版

有n盏灯,编号为1~n,第1个人把所有灯打开,第2个人按下所有编号为2的倍数的开关(这些灯将被关掉),第3个人按下所有编号为3的倍数的开关(其中关掉的灯被打开, 开着灯将被关闭),依此类推。一共有k个人,问最后有哪些灯开着? 输入:n和k,输出开着的灯编号。k≤n≤1000。 样例输入:7 3 样例输出:1 5 6 7 (题目描述拷贝自http://blog.csdn.net/oceaniwater/article/details/40709609) #include<stdio.h> int main() { int n,k,ni,ki,nii; //n=7;k=3; scanf("%d%d",&n,&k); for(ni=1;ni<=n;ni++)//灯数 { nii=ni; for(ki=1;ki<=k;ki++)//每灯人数 { //printf("%%%d ",nii%ki); if(nii%ki==0)//当前灯是否为当前人的倍数 { ni*=(-1);//负数为开,正数为灭 } //printf("!%d\n",ni); } if(ni<0) { printf("%d ",ni*=-1); } } return 0; }

SuCicada

刘汝佳p39,3-3(蛇形填数)算法竞赛入门经典第二版

在nn方阵里填入1,2,„,nn,要求填成蛇形。例如n=4时方阵为 10 11 12 1 9 16 13 2 8 15 14 3 7 6 5 4 上面的方阵中,多余的空格只是为了便于观察规律,不必严格输出。n≤8。 #include<iostream> #include<iomanip> using namespace std; int const N=120; int main() { int n[N][N]={0}; int m,mm; cin>>m; mm=m; int s=1,i,j; //s=n[i=0][j=m-1]=1; while(m--) { //m--; i=mm-m-1; j=m; while(i<=m-1 &&n[i][j]==0) n[i++][j]=s++;//right while(j>=mm-m &&n[i][j]==0) n[i][j--]=s++;//down while(i>=mm-m &&n[i][j]==0) n[i--][j]=s++;//left while(j<=m-1 &&n[i][j]==0) n[i][j++]=s++;//up if(s==mm*mm)n[i+1][j-1]=s; } for(i=0;i<mm;i++) { for(j=0;j<mm;j++) cout<<setw(3)<<n[i][j]; cout<<endl; } return 0; }

SuCicada

刘汝佳p41,3-4(竖式问题)算法竞赛入门经典第二版

题目: 找出所有形如abc*de(三位数乘以两位数)的算式,使得在完整的竖式中,所有数字都属于一个特定的数字集合。输入数字集合(相邻数字之间没有空格),输出所有竖式。每个竖式前应有编号,之后应有一个空行。最后输出解的总数。具体格式见样例输出(为了便于观察,竖式中的空格改用小数点显示,但你的程序应该输出空格,而非小数点)。 样例输入:2357 样例输出: <1> ..775 X..33 .—– .2325 .—– 25575 The number of solutions = 1 分析: 尝试所有的abc和de,判断是否满足条件。 #include<iostream> #include<string.h> #include<cstdio> using namespace std; int main() { char s[15],f[25]; int n=1; cin>>s; for(int a=100;a<1000;a++) { for(int b=10;b<=99;b++) { int o=1; int x=a*(b%10),y=a*(b/10),z=a*b; sprintf(f,"%d%d%d%d%d",a,b,x,y,z);//将abxyz输入到f中 for(int i=0;i<strlen(f);i++) if(strchr(s,f[i])==NULL) o=0; if(o) printf("<%d>\n%5d\nX%4d\n-----\n%5d\n%4d \n-----\n%5d\n\n",n++,a,b,x,y,z); } } cout<<"The number of solutions = "<<n-1<<endl; return 0; }

SuCicada

判断字符是否为字母或数字

参考: C语言中isalnum()函数和isalpha()函数的对比使用 C语言 判断字符的大小写 isalpha()函数 #include<ctype.h>//或<cctype> int isalpha(int ch)//为英文字母时返回不一定为1的非零,否则返回零 isalnum(c)//判断c是否为英文字母或数字 isupper(c)//判断c是否为大写英文字母 islower(c)//判断c是否为小写英文字母 isdigit(c)//判断c是否为数字 以上若不是所判断字符类型则都返回零

SuCicada

十六进制转十进制.h

#include<stdio.h> #include<ctype.h> int sc(char a[])//传进来代表十六进制的字符串数组,返回十进制 { int i,n=0,t; for(i=0;a[i];i++) { a[i]=toupper(a[i]); if(a[i]>='A') t=a[i]-'A'+10; else t=a[i]-'0'; n=n*16+t; } return n; }

SuCicada

Flume 的 发起: org.apache.flume.node.Application 我们看最后这里 application.start(); final Application appReference = application; Runtime.getRuntime().addShutdownHook(new Thread("agent-shutdown-hook") { @Override public void run() { appReference.stop(); } });

SuCicada

在Linux Mint 19 _ Linux Mint 18上安装VirtualBox 6.0 _ 5.2

如果你直接可以 sudo apt-get install virtualbox-6.0那就相安无事 否则参考 https://www.itzgeek.com/how-tos/linux/linux-mint-how-tos/install-virtualbox-4-3-on-linux-mint-17.html 打开终端并将Oracle VirtualBox存储库的公钥导入您的系统。 wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add - 使用以下命令添加VirtualBox存储库。 ### Linux Mint 19 ### echo“deb [arch = amd64] http://download.virtualbox.org/virtualbox/debian bionic contrib”| sudo tee /etc/apt/sources.list.d/virtualbox.list ### Linux Mint 18 ### echo“deb http://download.virtualbox.org/virtualbox/debian xenial contrib”| sudo tee /etc/apt/sources.list.d/virtualbox.list 更新存储库索引数据库。 sudo apt-get update 使用apt命令安装VirtualBox。 VirtualBox 6.0: sudo apt-get install -y virtualbox-6.0 VirtualBox 5.2: sudo apt-get install -y virtualbox-5.2 经历: 先参看官网方法:https://www.virtualbox.org/wiki/Linux_Downloads deb https://download.virtualbox.org/virtualbox/debian <mydist> contrib 增加源, <mydist> 里添加ubuntu的发行版 使用...

SuCicada

在树莓派 raspberrypi 系统中 安装rar unrar解压

参考 https://raspberrypi.stackexchange.com/questions/3617/how-to-install-unrar-nonfree 1.卸载unrar-free。 $ sudo apt-get remove unrar-free 2.通过编辑确保您拥有源存储库/etc/apt/sources.list。 $ cat /etc/apt/sources.list # Default repository deb http://archive.raspbian.org/raspbian wheezy main contrib non-free rpi # Source repository to add deb-src http://archive.raspbian.org/raspbian wheezy main contrib non-free rpi 3.同步apt数据库。 $ sudo apt-get update 4.创建一个工作目录并移入其中。该unrar-nonfree命令将在此目录中构建。 $ cd $(mktemp -d) 5.安装所需的依赖项unrar-nonfree。 $ sudo apt-get build-dep unrar-nonfree 6.下载unrar-nonfree源代码并构建.deb软件包。 $ sudo apt-get source -b unrar-nonfree 7.安装生成的.deb包。它的名称取决于版本unrar-nonfree。 $ sudo dpkg -i unrar*.deb 如果第六步报错如下: dpkg-buildpackage: info: binary-only upload (no source included) W: 由于文件'unrar-nonfree_5....

SuCicada

如何在 ClassPathXmlApplicationContext 里使用相对类路径的 xml文件

参考https://blog.csdn.net/upxiaofeng/article/details/53332226 URL a = this.getClass().getResource(""); // 获取ClassPath的绝对URI路径 // or URL a = 写你的类名.getResource(""); // 这里是反射的知识, String aa = a.toString(); // 转字符串 int begin = aa.indexOf("/bin")+5; aa = aa.substring(begin); // 切去 aa就是了 比如 String xmlPath = MainApp2.class.getResource("").toString(); xmlPath = xmlPath.substring(xmlPath.indexOf("/bin/")+5);

SuCicada

控制台光标移动(有尾迹)

更改了网上的代码,实现有尾迹的移动, 用键盘上的上下左右来控制 这是借鉴地址:C语言之实现控制台光标随意移动 #include <stdio.h> #include <windows.h> #include <conio.h> HANDLE hout; //获得输入 char getInput() { int ch; //输入字符串 COORD coord; //屏幕上的坐标 CONSOLE_SCREEN_BUFFER_INFO csbi; //控制台屏幕缓冲区信息 coord.X=11; coord.Y=10; ch=getch(); csbi.dwCursorPosition.X=11; csbi.dwCursorPosition.Y=10; //0x0d表示回车,0XE0表示上下左右等键的键码 while(ch==0xE0||ch==0x0d) { GetConsoleScreenBufferInfo(hout,&csbi);//读取控制台屏幕缓冲信息 coord.X=csbi.dwCursorPosition.X; //得到坐标X的值 coord.Y=csbi.dwCursorPosition.Y; //得到坐标Y的值 ch=getch(); //printf(" "); //上 if(ch==0x48) { if(coord.Y!=0) { coord.Y--; //printf("%c",'A'); } } //下 else if(ch==0x50) { coord.Y++; //printf("%c",'A'); } //左 else if(ch==0x4b) { if(coord.X!=0){coord.X--;}//printf("%c",'A');} } //右 else if(ch==0x4d) { if(coord.X!=79) { coord.X++; //printf("%c",'A'); } } printf("%c",'....

SuCicada

树莓派 raspberry系统 VNC View 连接 Cannot currently show the desktop 错误解决

https://www.raspberrypi.org/forums/viewtopic.php?t=216737 我是因为空间不够

SuCicada

比赛中使用文件输入输出

使用文件最简单的方式就是使用输入输出重定向 freopen("input.txt","r",stdin);//从文件读入 freopen("outout.txt","w",stdout);//写入文件 非重定向 #include<stdio.h> int main() { FILE *fin,*fout; int x; fin = fopen("input.txt","rb");//从文件读入 fout = fopen("outout.txt","wb");//写入文件 fscanf(fin,"%d",&x); fprintf(fout,"%d",x); fclose(fin); fclose(fout); return 0; }

SuCicada

求int型的最大取值(正数)

用的是夹值法 #include<stdio.h> int main(){ int i=1,n=1,m; do { n=i; i=i*2; printf("%d\n",n); } while((i/2)==n);//n是存数,i去趟雷 putchar('\n'); m=n; for(;;) { n=m; m+=1; if((m-1)!=n) { printf("break"); break; } else m-=1; i=1; while(1) { if(i!=1) if((n-i/2)!=m) { printf("int %d\n",m); return; } printf("!!!\n"); if(i!=1) m=n;//m是存数,n去趟雷 n=n+i; i*=2; printf("%d %d\n",m,n); } } getchar(); return 0; } 最大值:2147483647

SuCicada

求最长回文子串

一段字符串中出现的正反读一样的子串 当时自己写下的泛泛之词 #include<stdio.h> #define N 20 int main() { char a[N]="abcb"; char b[N]="0000"; int i,j,m; for(i=0;i<strlen(a)/2;i++) { for(j=i+1;j<strlen(a);j++) { if(a[i]==a[j]) { printf("%d %d %d ",i,j ,m); for(m=i;m<=j;m++) { if(a[m]!=a[j+i-m]) break; b[m-i]=a[m]; b[j-i-m]=a[j+i-m]; if((m==j+i-m)||(m==j+i-m-1)) i=j; printf("%s\n",b); } } } } printf("%s\n",b); return 0; }

SuCicada