别刀了别刀了

C语言迷宫问题

#include "stdio.h"
#include "stdlib.h"
#include "string.h"
char path[100];
int p=0;
void append(char c){path[p++]=c;}
struct kk{
    int x=0;
    int y=0;
    int p0=0;
    kk* last=NULL;
};
kk* pos=new kk;
void push(int y0,int x0,int p0){
    kk* np=new kk;
    np->x=x0;
    np->y=y0;
    np->p0=p;
    if(pos->last!=NULL)np->last=pos->last;
    pos->last=np;
}
void pop(int* y0,int* x0){
    pos=pos->last;
    *y0=pos->y;
    *x0=pos->x;
    p=pos->p0;
}
int main(int argc,char* argv[]) {
    if(argc!=2){printf("You must put one argument!");system("pause");return -1;}
    FILE *f=fopen(argv[1],"r");
    if(!f){printf("No such file or it's empty!");system("pause");return -1;}
    char a[43960];
    fscanf(f,"%*[^\n]\n%[^$]",a);strcat(a,"$\n");
    fclose(f);
    int line=0,column=1;
    for(int i=1;a[i]!='\n';i++,column++);
    for(int i=0;a[i]!='\0';i++)if(a[i]=='\n')line++;
    int x,y;
    x=column-2;y=line;
    bool maze[y][x];
    for(int i=0;i<y;i++)for(int j=0;j<x;j++)maze[i][j]=0;
    for(int i=0;i<y;i++)for(int j=0;j<x;j++)if(a[(column+1)*i+1+j]=='#')maze[i][j]=1;
    for(int x0=0,y0=0;;){
        if(x0==x&&y0==y)break;
        int count=0,cond=0;
        if(y0!=y-1&&maze[y0+1][x0]==0){cond+=1;count++;}//s
        if(y0!=0&&maze[y0-1][x0]==0){cond+=2;count++;}//w
        if(x0!=x-1&&maze[y0][x0+1]==0){cond+=4;count++;}//d
        if(x0!=0&&maze[y0][x0-1]==0){cond+=8;count++;}//a
        if(count==0){pop(&y0,&x0);continue;}
        if(count>1)push(y0,x0,p);
        if(cond==1||cond==3||cond==5||cond==7||cond==9||cond==11||cond==13||cond==15){maze[++y0][x0]=1;append('s');continue;}
        if(cond==2||cond==6||cond==10||cond==14){maze[--y0][x0]=1;append('w');continue;}
        if(cond==4||cond==12){maze[y0][++x0]=1;append('d');continue;}
        if(cond==8){maze[y0][--x0]=1;append('a');continue;}
    }
    for(int i=0;i<p;i++)printf("%c",path[i]);
    return 0;
}

/* sample 1
#####################
#*          #       #
########### ####### #
#   #   #   #     # #
### ### # # # ### # #
#     # # # # # #   #
##### # ### ### ### #
#       # #   #     #
####### # ### ##### #
#                  $#
#####################
*/
/* sample 2
#########################################
#*# #   #     #   #     # # # # # #     #
# # ### ### ##### ##### # # # # # ### ###
#   #         #   #       # # # #       #
### ######### # ####### ### # # ##### ###
# #           # #   # #   #   # # #   # #
# # ######### # ### # ### # ### # ### # #
#   #           # # # # # # #   #   # # #
# # ### ####### # # # # # # ### ### # # #
# # #   #   # # # # #       # #   # #   #
# ######### # # # # ####### # ### # # ###
#     #         # #   # # # #     # #   #
############### # ### # # # ##### # # ###
#   #   # #     #     #   # # #       # #
# # ### # ### # ##### ### # # ####### # #
# # #       # #     #   # #   #     #   #
### ####### ### ### # ### ### ### # # # #
# # #             #       # #     #   # #
# # ####### ### ### ##### # ####### # # #
#           #   #   #               # #$#
#########################################
 */

归个档,不会递归,走一手加权

纵横杯misc迷宫writeup(?

0xc0 国际惯例,先上exp

#!/usr/bin/env python
from pwn import *
context(os='linux', arch='amd64')


r=remote('182.92.203.154',11001) 
r.sendline()
r.recvuntil('start.')
from typing import *


maze = (r.recvuntil('\n>',drop=True).decode())

def find_path(maze: str) -> str:
    way = []
    maze_list = maze.split('\n')
    maze_height = len(maze_list)
    maze_width = len(maze_list[0])
    passed = [[0 for _ in range(maze_width)] for _ in range(maze_height)]

    def maze_helper(pos: Tuple[int, int]) -> bool:
        x, y = pos
        passed[y][x] = 1
        if maze_list[y][x] == '$':
            return True
        for i in 'adws':
            if i == 'a' and x > 0 and maze_list[y][x - 1] != '#' and passed[y][x - 1] != 1:
                way.append(i)
                if not maze_helper((x - 1, y)):
                    way.pop()
                else:
                    return True
            elif i == 'd' and x < maze_width - 1 and maze_list[y][x + 1] != '#' and passed[y][x + 1] != 1:
                way.append(i)
                if not maze_helper((x + 1, y)):
                    way.pop()
                else:
                    return True
            elif i == 'w' and y > 0 and maze_list[y - 1][x] != '#' and passed[y - 1][x] != 1:
                way.append(i)
                if not maze_helper((x, y - 1)):
                    way.pop()
                else:
                    return True
            elif i == 's' and y < maze_height - 1 and maze_list[y + 1][x] != '#' and passed[y + 1][x] != 1:
                way.append(i)
                if not maze_helper((x, y + 1)):
                    way.pop()
                else:
                    return True
        else:
            return False

    x, y = 0, 0
    for i, line in enumerate(maze_list):
        for j, value in enumerate(line):
            if value == '*':
                x, y = j, i
                break
        else:
            continue
        break
    maze_helper((x, y))
    return ''.join(way)

r.sendline(find_path(maze))
r.recvuntil('your win\n')

maze = (r.recvuntil('\n>',drop=True).decode())
r.sendline(find_path(maze))
r.recvuntil('your win\n')

maze = (r.recvuntil('\n>',drop=True).decode())
r.sendline(find_path(maze))
r.recvuntil('your win\n')

maze = (r.recvuntil('\n>',drop=True).decode())
r.sendline(find_path(maze))
r.recvuntil('your win\n')

maze = (r.recvuntil('\n>',drop=True).decode())
r.sendline(find_path(maze))
r.recvuntil('your win\n')

print(r.recvuntil('}',drop=False).decode())

四个迷宫,梭就完事了

小明怎么才能上网?

小明的难题

小明是中国某一不知名名校的电信学生,身在宿舍用不了网,寂寞难耐。他的墙上面板坏掉了,墙线断了,甚至在另一头的机架口也被人用松香堵上了,可谓是孤注一掷(x)现在让我们为他解决难题8

小明的室友有一个完好的面板,他想和舍友共享,但是舍友不给他路由器嫖,看来小明只能考虑其他方法了。恰好这位小朋友得知网线的1、2、3、6线是TX和RX的正负极线,也就是白橙、橙和白绿、绿。既然8根线只用了4根,小明哥要表演绝活了。

双头龙(无黄色)

我们小学二年级学过,双绞线中的B线序只有1、2、3、6被用于传输数据,如果配置适当,一根网线是可以同时建立两个物理连接而互不干扰的(如果不算电磁干扰的话)

网线结构网线结构

test

0xc0

原先写的幸运数,放在这里测试一下

#include "stdio.h"
int k1, k2;
bool isLucky(int a)
{ //isLucky(数,k1,k2)
int i, m;
for (i = 1, m = a; m / 10 >= 10; i++)
m = m / 10;
if (m == k1 || m == k2)
        return true;
    else
        return false;
}
int numOfnum(int a)
{
    int i, m;
    for (i = 1, m = a; m / 10 != 0; i++)
        m = m / 10; //判断位数i
    return i;
}
int numOfLucky(int a)
{
    int i, m, s;
    for (i = 1, m = a; m / 10 != 0; i++)
        m = m / 10; //判断位数i
    int b[i];
    for (m = i - 1, s = a; m >= 0; m--)
    {
        b[m] = s % 10;
        s = s / 10;
    } //给数组b赋上每位数
    for (m = 0, s = 0; m < i; m++)
        if (isLucky(b[m]))
            s++; //判断幸运数位数
    return s;
}
int main()
{
    int n;
    scanf("%d%d%d", &n, &k1, &k2);
    int a[n] = {0}, num[n] = {0};
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    for (int i = 0; i < n; i++)
        num[i] = numOfLucky(a[i]); //num数组与a数组一一对应
    int s = 0;
    for (int i = 1; i < n; i++)
    {
        if (num[i] > num[i - 1] && num[i] > num[s])
            s = i;
        if (numOfnum(a[i]) > numOfnum(a[s]) && num[i] == num[s])
            s = i;
    }
    printf("%d %d %d", a[s], num[s], numOfnum(a[s]));
    return 0;
}

Fatal error: Cannot redeclare getCanvas() (previously declared in /www/wwwroot/c0bis.cn/usr/plugins/Pio/Plugin.php:124) in /www/wwwroot/c0bis.cn/usr/plugins/Pio/Plugin.php on line 123