还有头发的程序员-
码龄4年
关注
提问 私信
  • 博客:11,069
    问答:6,737
    17,806
    总访问量
  • 2
    原创
  • 263,811
    排名
  • 129
    粉丝
  • 0
    铁粉
IP属地以运营商信息为准,境内显示到省(区、市),境外显示到国家(地区)
IP 属地:江苏省
  • 加入CSDN时间: 2021-05-13
博客简介:

weixin_58191539的博客

查看详细资料
  • 原力等级
    当前等级
    1
    当前总分
    74
    当月
    0
个人成就
  • 获得15次点赞
  • 内容获得1次评论
  • 获得24次收藏
创作历程
  • 1篇
    2024年
  • 1篇
    2022年
成就勋章
兴趣领域 设置
  • 大数据
    大数据
  • 最近
  • 文章
  • 代码仓
  • 资源
  • 问答
  • 帖子
  • 视频
  • 课程
  • 关注/订阅/互动
  • 收藏
搜TA的内容
搜索 取消

Spark.read多个文件且文件行列不同的非结构化文件解决办法

Spark.read在读取某个路径下 "/*.csv"(全部的csv文件的时候)他是随机读第一个文件来建表的!!!!并且和文件名和首行、首列都没有关系,完全随机读
原创
发布博客 2024.07.19 ·
688 阅读 ·
14 点赞 ·
0 评论 ·
13 收藏

能不能帮帮我,这个数据库我一直做不好

答:

你做到哪一步了,或者是遇到什么问题卡顿的

回答问题 2023.06.08

用mysql做一个酒店管理系统

答:

是页面和数据库都要吗

回答问题 2023.06.07

opencv检测点是否在轮廓内

答:

可以参考下

#include<opencv2/opencv.hpp>
#include<iostream>
 
using namespace cv;
using namespace std;
 
int main(int argc,char*argv)
{
    Mat src = Mat::zeros(Size(512, 512), CV_8UC1);
 
    vector<Point2f>Poly = { Point2f(50, 300), Point2f(100, 200),Point2f(200, 200),Point2f(250, 300), Point2f(200, 400), Point2f(100, 400) };
    for (size_t i = 0; i < 5; i++)
    {
        line(src, Poly[i], Poly[i + 1], Scalar(255), 1, 8, 0);
    }
    line(src, Poly[5], Poly[0], Scalar(255), 1);
    imshow("src",src);
 
    vector<vector<Point>>contours;
    findContours(src, contours, RETR_EXTERNAL, CHAIN_APPROX_NONE);
 
    Mat drawImg=Mat::zeros(src.size(),CV_32FC3);
    drawContours(drawImg, contours, -1, Scalar(0, 0, 255));
    imshow("drawImg", drawImg);
 
    Mat resultImg = Mat::zeros(src.size(), CV_32FC1);
    for (int row = 0; row < src.rows; row++)
    {
        for (int col = 0; col < src.cols; col++)
        {
            resultImg.at<float>(col,row) = (float)pointPolygonTest(contours[0], Point2f((float)row, (float)col), true);
        }
    }
    imshow("resultImg", resultImg);
    
    Mat dst = Mat::zeros(src.size(), CV_8UC3);
    for (int row = 0; row < src.rows; row++)
    {
        for (int col = 0; col < src.cols; col++)
        {
            float distance = resultImg.at<float>(col, row);
            if (distance>0.0)
            {
                dst.at<Vec3b>(col, row)[0] = distance;
            }
            else if (distance<0.0)
            {
                dst.at<Vec3b>(col, row)[1] = saturate_cast<uchar>(abs(distance));
                dst.at<Vec3b>(col, row)[2] = saturate_cast<uchar>(abs(distance));
            }
            else
            {
                dst.at<Vec3b>(col, row)[2] = 255;
            }
        }
    }
    imshow("dst", dst);
 
    waitKey();
    return 0;
}

回答问题 2023.06.05

C语言之中五子棋问题(附代码)

答:

试试这样呢

#include <stdio.h>
#include <stdlib.h>
#define MAX_ROW 15
#define MAX_COL 15
#define WHITE -1
#define BLACK 1
#define BLANK 0
 
void draw_chessboardn(int row, int col, int chessboard[][MAX_COL]);
void draw_chessman(int type, char *tableline);
int random_create_point(void);
void draw_menu(void);
void person_person(void);
void person_computer_random(void);
int is_full(int chessboard[][MAX_COL], int row, int col);
int is_win(int chessboard[][MAX_COL], int row, int col);
void save_chess(int chessboard[][MAX_COL], int row, int col);
void replay_chess(void);
int  ChooseArrow(int chessboard[][MAX_COL], int row, int col);
 
int main () {
    int choice;
    draw_menu();
    while (1) {
        scanf("%d", &choice);
        switch (choice) {
            case 1:
                person_person();
                break;
            case 2:
                person_computer_random();
                break;
            case 3:
                replay_chess();
                break;
            case 4:
                exit(0);
                break;
            default:
                printf("输入错误,请重新选择\n");
        }
    }
    return 0;
}
//绘制棋盘
void draw_chessboardn(int row, int col, int chessboard[][MAX_COL]) {
    for (int i = 0; i < row ; i++) {
        if (i == 0) {
            for (int j = 0; j < col; j++) {
                if (j == 0)
                    draw_chessman(chessboard[i][j], "┌ ");
                else if (j == 14)
                    draw_chessman(chessboard[i][j], "┐");
                else
                    draw_chessman(chessboard[i][j], "┬ ");
            }
            printf("\n");
        } else if (i == 14) {
            for (int j = 0; j < col; j++) {
                if (j == 0)
                    draw_chessman(chessboard[i][j], "└ ");
                else if (j == 14)
                    draw_chessman(chessboard[i][j], "┘ ");
                else
                    draw_chessman(chessboard[i][j], "┴ ");
            }
            printf("\n");
        } else {
            for (int j = 0; j < col; j++) {
                if (j == 0)
                    draw_chessman(chessboard[i][j], "├ ");
                else if (j == 14)
                    draw_chessman(chessboard[i][j], "┤");
                else
                    draw_chessman(chessboard[i][j], "┼ ");
            }
            printf("\n");
        }
    }
}
//绘制棋子
void draw_chessman(int type, char *tableline) {
    if (type == WHITE)
        printf("●");
    if (type == BLACK)
        printf("○");
    if (type == BLANK)
        printf("%s", tableline);
}
//随机算法获取棋子的坐标
int random_create_point(void) {
    int point;
    point = rand() % MAX_ROW;
    return point;
}
//绘制主菜单
void draw_menu(void) {
    printf("******************************\n");
    printf("******* 欢迎使用五子棋 *******\n");
    printf("***     研发者:Hiya(a     ***\n");
    printf("***     请选择对战方式     ***\n");
    printf("*      1.人-人对战           *\n");
    printf("*      2.人-机对战(随机算法) *\n");
    printf("*      3.复盘                *\n");
    printf("*      4.退出                *\n");
    printf("******************************\n");
    printf("请选择:");
}
//人人对战
void person_person(void) {
    int chessboard[MAX_ROW][MAX_COL] = {BLANK};
    int i, j;
    char key;
    draw_chessboardn(MAX_ROW, MAX_COL, chessboard);
    for (int step = 1; step <= MAX_ROW * MAX_COL; step++) {    //黑子先行,然后双方轮流下棋
        if (step % 2 == 1) {                                   //当前步数为单数,黑棋落子。
            printf("请黑棋落子:");
            while (1) {
                scanf("%d %d", &i, &j);
                if (chessboard[i][j] != BLANK) {
                    printf("该位置已有棋子,请重新输入\n");        //棋子只能落在空白处
                    continue;
                }
                if (i >= MAX_ROW || j >= MAX_COL || i < 0 || j < 0) {
                    printf("输入超出棋盘范围,请重新输入\n");      //棋子坐标不可超出棋盘
                    continue;
                }
                break;
            }
            chessboard[i][j] = BLACK;
            draw_chessboardn(MAX_ROW, MAX_COL, chessboard);
            if (is_win(chessboard, MAX_ROW, MAX_COL) == BLACK) {
                printf("黑棋胜");
                exit(0);
            }
            save_chess(chessboard, MAX_ROW, MAX_COL);
        } else if (step % 2 == 0) {                            //当前步数为双数,则白棋落子
            printf("请白棋落子:");
            while (1) {
                scanf("%d %d", &i, &j);
                if (chessboard[i][j] != BLANK) {
                    printf("该位置已有棋子,请重新输入\n");        //棋子只能落在空白处
                    continue;
                }
                if (i >= MAX_ROW || j >= MAX_COL || i < 0 || j < 0) {
                    printf("输入超出棋盘范围,请重新输入\n");     //棋子坐标不可超出棋盘
                    continue;
                }
                break;
            }
            chessboard[i][j] = WHITE;
            draw_chessboardn(MAX_ROW, MAX_COL, chessboard);
            if (is_win(chessboard, MAX_ROW,  MAX_COL) == WHITE) {
                printf("白棋胜");
                exit(0);
            }
            save_chess(chessboard, MAX_ROW, MAX_COL);
        }
    }
    if (is_full(chessboard, MAX_ROW, MAX_COL) == 1)
        printf("棋盘已满");
}
//判断棋盘是否已满
int is_full(int chessboard[][MAX_COL], int row, int col) {
    int ret = 1;
    for (int i = 0; i < row; i++) {
        for (int j = 0; j < col; j++) {
            if (chessboard[i][j] == BLANK) {        //遍历数组,当有一个位置为空,则棋盘不满
                ret = 0;
                break;
            }
        }
    }
    return ret;
}
//判断胜负
int is_win(int chessboard[][MAX_COL], int row, int col) {
    int i, j;
    for (i = 0; i < row; i++) {
        for (j = 0; j < col; j++) {
            if (chessboard[i][j] == BLANK)
                continue;
            if (j < col - 4)
                if (chessboard[i][j] == chessboard[i][j + 1] && chessboard[i][j] == chessboard[i][j + 2]
                        && chessboard[i][j] == chessboard[i][j + 3] && chessboard[i][j] == chessboard[i][j + 4])
                    return chessboard[i][j];
            if (i < row - 4)
                if (chessboard[i][j] == chessboard[i + 1][j] && chessboard[i][j] == chessboard[i + 2][j]
                        && chessboard[i][j] == chessboard[i + 3][j] && chessboard[i][j] == chessboard[i + 4][j])
                    return chessboard[i][j];
            if (i < row - 4 && j < col - 4)
                if (chessboard[i][j] == chessboard[i + 1][j + 1] && chessboard[i][j] == chessboard[i + 2][j + 2]
                        && chessboard[i][j] == chessboard[i + 3][j + 3] && chessboard[i][j] == chessboard[i + 4][j + 4])
                    return chessboard[i][j];
            if (i < row - 4 && j > 4)
                if (chessboard[i][j] == chessboard[i + 1][j - 1] && chessboard[i][j] == chessboard[i + 2][j - 2]
                        && chessboard[i][j] == chessboard[i + 3][j - 3] && chessboard[i][j] == chessboard[i + 4][j - 4])
                    return chessboard[i][j];
        }
    }
    return BLANK;
}
//人机对战
void person_computer_random(void) {
    int chessboard[MAX_ROW][MAX_COL] = {BLANK};
    int i, j;
    draw_chessboardn(MAX_ROW, MAX_COL, chessboard);
    for (int step = 1; step <= MAX_ROW * MAX_COL; step++) {
        if (step % 2 == 1) {
            printf("请黑棋落子:");
            while (1) {
                scanf("%d %d", &i, &j);
                if (chessboard[i][j] != BLANK) {
                    printf("该位置已有棋子,请重新输入\n");
                    continue;
                }
                if (i >= MAX_ROW || j >= MAX_COL || i < 0 || j < 0) {
                    printf("输入超出棋盘范围,请重新输入\n");
                    continue;
                }
                break;
            }
            chessboard[i][j] = BLACK;
            draw_chessboardn(MAX_ROW, MAX_COL, chessboard);
            if (is_win(chessboard, MAX_ROW, MAX_COL) == BLACK) {
                printf("黑棋胜");
                exit(0);
            }
            save_chess(chessboard, MAX_ROW, MAX_COL);
        } else if (step % 2 == 0) {
            while (1) {
                i = random_create_point();
                j = random_create_point();
                if (chessboard[i][j] == BLANK)
                    break;
            }
            chessboard[i][j] = WHITE;
            draw_chessboardn(MAX_ROW, MAX_COL, chessboard);
            if (is_win(chessboard, MAX_ROW,  MAX_COL) == WHITE) {
                printf("白棋胜");
                exit(0);
            }
            save_chess(chessboard, MAX_ROW, MAX_COL);
        }
    }
    if (is_full(chessboard, MAX_ROW, MAX_COL) == 1)
        printf("棋盘已满");
}
//存盘
void  save_chess(int chessboard[][MAX_COL], int row, int col) {
    int choice ;
    FILE *fp;
    printf("是否选择结束游戏,并保存当前棋局\n");
    printf("*********1.存盘并退出***********\n");
    printf("*********2.继续游戏*************\n");
    printf("请选择 :");
    while (1) {
        scanf("%d", &choice);
        if (choice > 2) {
            printf("输入错误,请重新选择\n");
            continue;
        }
        break;
    }
    if (choice == 1) {
        if ( ( fp = fopen( "Save_chess.txt", "w" ) ) == NULL ) {
            printf(" 保存失败\n");
        } else {
            for (int i = 0; i < row; i++) {
                for (int j = 0; j < col; j++) {
                    fprintf(fp, "%d", chessboard[i][j]);
                }
            }
            fclose(fp);
            printf("恭喜您,保存成功");
        }
        exit(0);
    }
}
//复盘
void replay_chess(void) {
    int  chessboard[MAX_ROW][MAX_COL] = {BLANK};
    FILE *fp;
    char ch;
    if ((fp = fopen("Save_chess.txt", "w")) == NULL) {
        printf("复盘失败");
    } else {
        for (int i = 0; i < MAX_ROW; i++) {
            for (int j = 0; j < MAX_COL; j++) {
                fscanf(fp, "%d", chessboard[i][j]);
            }
        }
        fclose(fp);
        draw_chessboardn(MAX_ROW, MAX_COL, chessboard);
    }
}

回答问题 2023.06.05

面向对象程序设计java设计

答:

用Java实现简易的图书管理系统(超详细)

public class Book {
    private String name;
    private String author;
    private int price;
    private String type;
    private boolean isBorrowed; //是否被借出
    //构造器
    public Book(){
 
    }
    public Book(String name,String author,int price,String type){
        this.author=author;
        this.name=name;
        this.price=price;
        this.type=type;
    }
 
    //get、set方法
    public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public String getAuthor() {
        return author;
    }
 
    public void setAuthor(String author) {
        this.author = author;
    }
 
    public int getPrice() {
        return price;
    }
 
    public void setPrice(int price) {
        this.price = price;
    }
 
    public String getType() {
        return type;
    }
 
    public void setType(String type) {
        this.type = type;
    }
 
    public boolean isBorrowed() {
        return isBorrowed;
    }
 
    public void setBorrowed(boolean borrowed) {
        isBorrowed = borrowed;
    }
@Override
//重写toString()
    public String toString() {
        return "Book{" +
                "书名:'" + name + '\'' +
                ", 作者:'" + author + '\'' +
                ", 价格:" + price +
                ", 类型:'" + type + '\'' +
                ", 是否借出:" + isBorrowed +
                '}';
    }
}
import java.util.ArrayList;
 
public class BookList {
    private ArrayList<Book> books=new ArrayList<Book>();
    public BookList() {
        books.add(new Book("三国演义","罗贯中",19,"小说"));
        books.add(new Book("西游记","吴承恩",29,"小说"));
        books.add(new Book("红楼梦","曹雪芹",25,"小说"));
    }
    public Book getBook(int pos){ //获取某个位置上的书籍
        return books.get(pos);
    }
    public void setBook(int pos,Book book){ //设置某个位置上的书籍
        books.set(pos,book);
    }
    public ArrayList<Book> getBooks(){  //获取书架,便于后面的Operation的使用
        return books;
    }
}

回答问题 2023.06.05

八路抢答器倒计时设计时显示器不输出,只能显示0

答:

51单片机的八路抢答器设计
可以参考下

void main()
{
int djs1=60;
Timer0_init();     //初始化定时器中断
spk=1;              //蜂鸣器不响
        djs=60;        //倒计时赋值
while(1)
{
 
LOOP1:   
djs=djs1;
djsxs22();    //LOOP1是标号,显示 -  --
 
if(key1==0)         //在定时器运行状态下,key1==0 则说明1号选手按下按键
{
   delayms(3);
   if(key1==0)
   { 
      while(!key1);      //去除按键抖动后,重新在判断,是否确实按下
      djs=60;
      while(1)
      {
         TR0=0;          //定时器停止
         djsxs();      
         if(key2==0)      //复位按下按下
         {    
             delayms(8);           //去除抖动
             if(key2==0)       //再次判断是否按下复位按键
             {
                 do
                 { 
                     while(!key2); //如果按下复位键,则回到- --状态
                     delayms(5);
                 }
                 while(key2!=1);
                 djs++;
                 djs1=djs;
             }
          }
          if(key3==0)      //复位按下按下
          {    
             delayms(8);           //去除抖动
             if(key3==0)       //再次判断是否按下复位按键
             { 
                do
                {
                    while(!key3); //如果按下复位键,则回到- --状态
                    delayms(5);    
                }
                while(key3!=1);
                djs--;
                djs1=djs;
             }
           }
           if(key1==0)      //复位按下按下
           {    
              delayms(3);           //去除抖动
              if(key1==0)       //再次判断是否按下复位按键
              { 
                 while(!key1); //如果按下复位键,则回到- --状态
                 goto LOOP1;          //goto语句,回到loop1表号处
              }
           }                                           
         }
       }
     }
     if(keyks==0)
     {           
        //spk=0;
        delayms(3);         //去除按键抖动
        if(keyks==0)
        { 
           while(!keyks);      //以上表示按下开始按键 
           //spk=1;               //蜂鸣器不响
           TR0=1;               //启动定时器 开始倒计时
           while(1)
           {
              djsxs();
              if(keytz==0)
              {
                  delayms(3);             //此处表示出去抖动, 以后不一一标出
                  if(keytz==0)
                  { 
                     while(!keytz);       //以上表示按下停止按键后 
                     {
                        TR0=0;           //定时器停止
                        flag=0;//
                        spk=1;
                     }
 
                   }
               }
               if(keyks==0)
               {
                  //spk=0;
                  delayms(3);
                  if(keyks==0)
                  { 
                     while(!keyks);       //以上表示按下清楚按键后 
                     //spk=1;               //蜂鸣器不响
                     TR0=1;           //定时器启动
 
                  }
                }
                .......
              } 
 
            }
 
         }
      }
   }
}

回答问题 2023.06.05

滤波器频率特性分析(私信我,发具体要求,有偿)

答:

Matlab滤波器设计与滤波器特性分析(sptool、filterdesigner)

可以参考下,非常详细
https://blog.csdn.net/qq_52065352/article/details/111558268

回答问题 2023.06.05

Scratch~汽车小游戏

答:

用scratch做赛车小游戏
可以借鉴下
http://www.peixun360.com/2499/news/424995/

回答问题 2023.06.05

OSGB转换为3dtiles

答:

引用部分chatgpt

可能是由于在OSGB和3dtiles中坐标系的定义不同导致的。OSGB使用的是东北天坐标系(ENU),而3dtiles使用的是右手笛卡尔坐标系(XYZ),其中X轴指向东方,Y轴指向北方,Z轴指向天空。

在进行OSGB到3dtiles的转换时,需要将OSGB中的坐标系转换为3dtiles中的坐标系。这个转换过程需要考虑到坐标系之间的旋转和平移。在旋转方面,需要将ENU坐标系旋转90度,使其X轴指向东方,Y轴指向北方;在平移方面,需要将ENU坐标系的原点设置为3dtiles坐标系的原点。

如果在转换过程中出现了X和Y反转的情况,可能是由于旋转和平移的顺序不正确或者旋转的角度不正确导致的。可以尝试调整旋转和平移的顺序,或者调整旋转的角度,以解决这个问题。

回答问题 2023.06.05

超多因素的正交方案设计

答:

引用chatgpt

在 MATLAB 中,可以使用 "orthogonalfir" 函数生成正交试验表。这个函数可以生成具有不同长度和不同阶数的正交试验表,以满足不同的实验设计需要。下面是一个生成长度为 8 和阶数为 4 的正交试验表的示例代码:

复制
% 设置参数
len = 8; % 正交试验表长度
order = 4; % 正交试验表阶数

% 生成正交试验表
X = orthogonalfir(len, order);

% 显示试验表
disp(X);
这段代码将生成一个 8 行 4 列的正交试验表,并将其显示在 MATLAB 命令窗口中。你可以根据自己的实验设计需要调整参数,生成不同长度和阶数的正交试验表。

回答问题 2023.06.05

用C语言随机生成一个迷宫

答:

试试这个

#include<stdio.h> 
#include<stdlib.h>
#include<time.h>
#include<conio.h>
 
struct Node
{
    int data;
    int flag;
};
 
struct Path
{
    int xpath;
    int ypath;
    int pox;    //在队列中的下标 
};
 
//全局变量
int n, m;     //迷宫的行和列 
Node* maze;   //迷宫存放 
Path* que;
int top = -1;
int front = -1;
int rear = -1;
 
void create()
{
    int i, j;
    printf("输入迷宫(随机生成)的行和列:");
    scanf("%d%d", &n, &m);
    maze = new Node[n * m];
    srand(time(NULL));
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            int temp = rand() % 4;
            if (temp != 1) maze[i * m + j].data = 1;
            else maze[i * m + j].data = 0;
            maze[i * m + j].flag = 0;
        }
    }
    maze[0].data = 8;  //设置起点 
    maze[n * m - 1].data = 1;
    printf("生成迷宫:\n");
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            printf("%d", maze[i * m + j].data);
        }
        printf("\n");
    }
}
int judge_head()
{
    int k = 1;
    if (que[front].xpath == n - 1 && que[front].ypath == m - 1)
    {
        printf("找到迷宫的通路!\n");
        int x = que[front].xpath;
        int y = que[front].ypath;
        int t = que[front].pox;    //前一个坐标在队列的下标 
        while (x != 0 || y != 0)
        {
            maze[x * m + y].data = 8;
            x = que[t].xpath;
            y = que[t].ypath;
            t = que[t].pox;
            k++;
        }
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                printf("%d", maze[i * m + j].data);
            }
            printf("\n");
        }
        printf("路径长度为:%d\n", k);
        return 1;
    }
    return 0;
}
void push_road(int x, int y)
{
    if (maze[x * m + y].data == 1 && maze[x * m + y].flag == 0)
    {
        que[(++rear) % (n * m)].xpath = x;
        que[rear % (n * m)].ypath = y;
        que[rear % (n * m)].pox = front;   //设置上一个坐标在队列中的位置 
        maze[x * m + y].flag = 1;
    }
}
/*搜索路径*/
void seek_road()   /*先实现一个路径先*/
{
    //path = new Path[n*m];
    int x1, y1;
    que = new Path[n * m];                  //利用广度优先实现最短路径
    que[0].xpath = 0;
    que[0].ypath = 0;
    que[0].pox = 0;
    maze[0].flag = 1;
    rear++;
    while (front != rear)
    {
        int x = que[(++front) % (n * m)].xpath;  //获取队头的坐标,然后将其四周的通路进队,知道操作完队尾元素 
        int y = que[front % (n * m)].ypath;
        //    path[++top] = que[front];
        if (judge_head()) return;
        if (y + 1 < m)
            push_road(x, y + 1);
        if (x + 1 < n)
            push_road(x + 1, y);
        if (y - 1 >= 0)
            push_road(x, y - 1);
        if (x - 1 >= 0)
            push_road(x - 1, y);
    }
    printf("没有通路!\n");
}
int main()
{
    create();
    seek_road();
    return 0;
}

回答问题 2023.06.05

JavaWeb实验(购物平台)

答:

可以参考下
1.登录和注册

//1.判读用户请求的类型为login
        String method = req.getParameter("type");
        switch (method) {
            case "login":
                // 从 login.html中 拿 账号,密码等数据
                String name = req.getParameter("name");
                String pwd = req.getParameter("pwd");

                //  调用UserBiz的getUser方法,根据 网页中 输入的账号密码,获取相应对象
                User user = userBiz.getUser(name,pwd);

                 //判断 获取到的对象是否为 null;
                 if (user == null) {
                     System.out.println(user);
                     out.println("<script>alert('用户名或密码不存在');location.href = 'login.html';</script>");
                 }else {

                     session.setAttribute("user",user);//user-->Object
                     out.println("<script>alert('登录成功');location.href='/UserShow';</script>");
                 }

                 break;
            case "register" :

                // 从 login.html中 拿 账号,密码等数据
                String name1 = req.getParameter("name");
                String pwd1 = req.getParameter("pwd");
                UserDao userDao = new UserDao();
                try {
                    userDao.setUser(name1,pwd1);
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
                out.println("<script>alert('注册成功');location.href = 'login.html';</script>");
                break;



回答问题 2023.06.05

S3C44B0X片外flash程序用JFLASH读回错误

答:

简化版的Jlink不适用JFlash这个软件,用标准的Jlink。

回答问题 2023.06.05

用React或js来循环给盒子添加点击事件

答:

可以参考下

function Tetris(pos, type, dir) {
    this.turn = function () {
        var flag = 1;
        switch (this.types_name[this.type]) {
            case "SQUARE":
                return true;
            case "LINE":
                flag = this.tetris[1].y-this.centor.y?1:-1;
                break;
            case "SWAGERLY":
            case "RSWAGERLY":
                flag = this.tetris[2].y-this.centor.y?1:-1;
                break;
            case "LBLOCK":
            case "RLBLOCK":
            case "TBLOCK":
                flag = 1;
                break;
        }
        for (var i = 1; i < this.tetris.length; i++) {
            var diff = {"x":this.tetris[i].x-this.centor.x, "y":this.tetris[i].y-this.centor.y};
            this.tetris[i].x = this.centor.x + flag*diff.y;
            this.tetris[i].y = this.centor.y - flag*diff.x;
        }
        return true;
    }
    this.turnback = function () {
        if (this.types_name[this.type] == "SQUARE")
            return true;
        for (var i = 0; i < 3; i++)
            this.turn();
    }
    this.leftSlice = function () {
        this.pos.x--;
    }
    this.rightSlice = function () {
        this.pos.x++;
    }
    this.drop = function () {
        this.pos.y++;
    }
    this.rise = function() {
        this.pos.y--;
    }
    this.body = function () {
        var body = [];
        for (var i = 0; i < this.tetris.length; i++) {
            if (this.tetris[i].y+this.pos.y >= 0)
                body.push({"x":this.tetris[i].x+this.pos.x, "y":this.tetris[i].y+this.pos.y});
        }
        return body;
    }
    this.__init__ = function () {
        var arr = this.types_body[this.type];
        this.tetris = [];
        this.centor = {"x":arr[0]%4-this.origin%4, "y":parseInt(arr[0]/4)-parseInt(this.origin/4)};
        for (var i = 0; i < 4; i++) {
            this.tetris[i] = {"x":arr[i]%4-this.origin%4, "y":parseInt(arr[i]/4)-parseInt(this.origin/4)};
        }
    }
    this.types_name = ["LBLOCK", "RLBLOCK", "TBLOCK", "SWAGERLY", "RSWAGERLY", "LINE", "SQUARE"];
    this.types_body = [
        [5, 1, 2, 9], //LLL
        [6, 1, 2,10],
        [5, 1, 4, 6], //T 
        [5, 2, 6, 9], //555 
        [5, 1, 6,10], 
        [5, 4, 6, 7], //I
        [5, 0, 1, 4],
    ]
    this.origin = 5;
    this.type = type%7;
    this.pos = pos;
    this.__init__();
    for (i = 0; i < dir%4; i++)
        this.turn();
    return this;
}

回答问题 2023.06.05

有关c++的一些实验问题

答:

可以借鉴下



#include <iostream>
#include <string>
#include <math.h>
using namespace std;
class Shape
{
public:
    virtual double area() = 0;
    virtual double Ctrcumference() = 0;

};

class Circle : public Shape
{
public:
    Circle(double r) :radius(r) {}
    virtual double area() { return 3.14 * radius * radius; }
    virtual double Ctrcumference() { return 2 * 3.14 * radius; }

protected:
    double radius;
};

class Recentage : public Shape
{
public:
    Recentage(double l, double w) : longth(l), width(w) {}
    virtual double area() { return longth * width; }
    virtual double Ctrcumference() { return 2 * (longth * width); }

protected:
    double longth;
    double width;
};


class Triangle : public Shape
{
public:
    Triangle(double l, double w) : longth(l), width(w) {}
    virtual double area()   { return  0.5 * longth * width; }
    virtual double Ctrcumference() { return (longth + width + sqrt(longth * longth + width * width)); }

protected:
    double longth;
    double width;
};
class Ellipse : public Shape
{
public:
    Ellipse(double sa, double la) { short_as = sa; long_as = la; }
    virtual double area() { return 3.14 * short_as * long_as; }
    virtual double Ctrcumference() { return (2 * 3.14 * short_as + 4 * (long_as - short_as)); }
protected:
    
    double short_as;
    double long_as;


};



void printArea_Ctr(Shape& s)
{
    cout <<"面积:"<< s.area() <<","<< "周长:"<<s.Ctrcumference() << endl;
}


void Meum_Selcet()
{
    cout << "-----------欢迎使用几何图形运算-----------------" << endl;
    cout << "           number 0: circle(圆)" << endl;
    cout << "           number 1: Recentage(矩形)" << endl;
    cout << "           number 2: Triangle(三角形)" << endl;
    cout << "           number 3: ellipse(椭圆)" << endl;
    cout << "           number else: 四种几何图形的周长,面积总和 " << endl;

}

int main()
{
    Meum_Selcet();
loop:
    {
        double ToTal_Area = 0;
        double ToTal_Ctr = 0;

        cout << "Please choose the parterns of the Geometric Calculation:" << endl;
        int choose = 0;
        cin >> choose;
        switch (choose)
         {
            case 0:
            {
                double r = 0;
                cout << "Please enter the menbers of Circle:" << endl;
                cin >> r;
                Circle circle(r);
                cout << "the area and the ctrcumference of the circle:" << endl;
                printArea_Ctr(circle);

            }; break;
            case 1:
            {    cout << "Please enter the menbers of recentage:" << endl;
                double lo = 0; double  wi = 0;
                cin >> lo >> wi;
                Recentage recentage(lo, wi);
                cout << "the area and the ctrcumference of the recentage:" << endl;
                printArea_Ctr(recentage);
            }; break;
            case 2:
            {    cout << "Please enter the menbers of triangle:" << endl;
                double lt = 0; double wt = 0;
                cin >> lt >> wt;
                Triangle triangle(lt, wt);
                cout << "the area  and the ctrcumference of the triangle:" << endl;
                printArea_Ctr(triangle);
            }; break;
            case 3:
            {
                cout << "Please enter the menbers of ellipse:" << endl;
                double sl = 0; double ll = 0;
                cin >> sl >> ll;
                Ellipse ellipse(sl, ll);
                cout << "the area and the ctrcumference of ellipse:" << endl;
                printArea_Ctr(ellipse);
            }; break;
            default:
            {   cout << "Please enter the parameters of the four Geometry: " << endl;
                cout << "圆半径,矩形长宽,三角形底和高,椭圆长短半轴:" << endl;
                double r1, lo1, wi1, lt1, wt1, sl1, ll1;
                cin >> r1 >> lo1 >> wi1 >> lt1 >> wt1 >> sl1 >> ll1;
                Circle circle(r1);
                Recentage recentage(lo1, wi1);
                Triangle triangle(lt1, wt1);
                Ellipse ellipse(sl1, ll1);
                ToTal_Area = circle.area() + recentage.area() + triangle.area() + ellipse.area();
                ToTal_Ctr = circle.Ctrcumference() + recentage.Ctrcumference() + triangle.Ctrcumference() + ellipse.Ctrcumference();
                cout << "派生类对象的面积之和、周长之和:" << endl;
                cout << ToTal_Area << "," << ToTal_Ctr << endl;
            }; break;
        }
        cout << '\n' << "输入Left离开计算界面/输入Continue继续进行运算" << endl;
        string ch;
        cin >> ch;
        if (ch == "Left")
            cout << "————————感谢使用几何图形运算!——————————" << endl;

        else if (ch == "Continue")
            goto loop;
        else
            cout << "请重新选择(Left or Continue)!" << endl;

    }
    return 0;


}

回答问题 2023.06.05

制作流水灯,保存文件,两份不一样的

答:

51单片机入门——Proteus上流水灯的实现
可以参考下
https://blog.csdn.net/weixin_64313535/article/details/130141133

回答问题 2023.06.04

为什么我的电平读取不完整呢?

答:

可能是这几个问题


1、串口DMA配置问题:先初始化dma通道,防止串口接收、溢出等标志位置位导致dma工作异常,dma优先级不够高导致被其他dma打断
2、CACHE的使用:网上能找到很多相关资料,不在此处说明
3、硬件模块的原因:板子是自己做的,模块采用了一个mos管来控制电源管理,实际排查发现这个mos管内阻原因存在压降,使得低电平无法被识别到,从而影响到stm32的数据接收

回答问题 2023.06.04

MATLAB中,图顶点数量多,怎么快速生成图

答:

clear all
% close all
load('matlab.mat');
x_max = max(u_4(:,1));x_min = min(u_4(:,1));
y_max = max(u_4(:,2));y_min = min(u_4(:,2));
z_max = max(u_4(:,3));z_min = min(u_4(:,3));
x = u_4(:,1);
y = u_4(:,2);
z = u_4(:,3);
%%
x_num = 256;
y_num = 256;
x_delt = (x_max-x_min)/(x_num-1);
y_delt = (y_max-y_min)/(y_num-1);
cx = linspace(x_min,x_max,x_num-1);
cy = linspace(y_min,y_max,y_num-1);
c_data = zeros(x_num,y_num);
c_data_num = c_data;
c2 = nan * zeros(x_num,y_num);
x2 = floor((x-x_min)/x_delt)+1;
y2 = floor((y-y_min)/y_delt)+1;
tic
for i = 1:length(z)
   c_data(x2(i),y2(i)) = c_data(x2(i),y2(i))+z(i);
   c_data_num(x2(i),y2(i)) = c_data_num(x2(i),y2(i))+1;
%    if ~mod(i,10000) disp(num2str(i));end
end
toc
gx = c_data./c_data_num;
figure;surf(gx');view(0,90);shading interp;colormap(hsv)

回答问题 2023.06.04

如何调用wx.updateShareMenu这个函数

答:

可以看看

<script>
  export default {
    data() {
      return {
      }
    },
    created() {
        //设置私密消息,在群聊中也不可转发
        wx.updateShareMenu({
         isPrivateMessage: true,//只是做禁止分享可以不用activityId
        })
        //隐藏三个点的分享到朋友圈和转发好友或群的按钮
        wx.hideShareMenu({
          menus: ['shareAppMessage', 'shareTimeline']
          })
          //进入后判断是否是白名单人员
        this.isWhitelist()
    },
    methods: {
    //判断是否是白名单
      async isWhitelist() {
        const res = await isWhitelist();
        if (res.success) {
         if(res.result.isStaff){
             wx.showShareMenu({
                menus: ['shareAppMessage', 'shareTimeline']
            })
         }
         }
        },    
      },
    }
</script>



回答问题 2023.06.04
加载更多