请选择 进入手机版 | 继续访问电脑版

用Java写了一个小猪效果图:

回答|共 65 个

legs+

legs+ 发表于 2022-11-20 18:35:29| 字数 70 | 显示全部楼层

孤星11 发表于 2022-11-20 17:55
Visual Studio可以支持C++, C#, VB.NET,ASP.NET, Python等等。

点评

谢谢你的答复。  发表于 2022-11-20 19:23

legs+

legs+ 发表于 2022-11-20 18:51:56| 字数 45 | 显示全部楼层

IntelliSense,对,我艹,chrome不支持Google翻译,edge反而翻译。

孤星11

孤星11 发表于 2022-11-20 19:23:14| 字数 83 | 显示全部楼层

legs+ 发表于 2022-11-20 18:51
IntelliSense,对,我艹,chrome不支持Google翻译,edge反而翻译。

你们那里谷歌翻译被终止服务了。

legs+

legs+ 发表于 2022-11-20 19:29:43| 字数 34 | 显示全部楼层

是的,但是同样是edge,同样用chrome的Google插件,可以

legs+

legs+ 发表于 2022-11-20 19:34:22| 字数 0 | 显示全部楼层

360截图20221120193359470.jpg

legs+

legs+ 发表于 2022-11-21 12:19:56| 字数 1,730 | 显示全部楼层

  1. @Controller
  2. @RequestMapping("thymeleaf")
  3. public class ThymeleafController {
  4.     @GetMapping("/variable")
  5.     public ModelAndView variable() {
  6.         ModelAndView modelAndView = new ModelAndView("thymeleaf");
  7.         String name = "liulihui";
  8.         Integer age=45;
  9.         modelAndView.addObject("name", name);
  10.         modelAndView.addObject("age", age);

  11.         return modelAndView;
  12.     }
  13.     @GetMapping("/")
  14.     public ModelAndView index() {
  15.         ModelAndView modelAndView = new ModelAndView("index");
  16.          return modelAndView;
  17.     }
  18.     @GetMapping("/list")
  19.     public ModelAndView list() {
  20.         List<Object> list = new ArrayList<Object>();
  21.         list.add("北京");
  22.         list.add("上海");
  23.         list.add("深圳");
  24.         ModelAndView modelAndView = new ModelAndView("list");
  25.         modelAndView.addObject("list", list);
  26.         return modelAndView;
  27.     }
  28.     @GetMapping("/list2")
  29.     public ModelAndView list2() {
  30.         List<User> list = new ArrayList<>();
  31.         list.add(new User(1,"long"));
  32.         list.add(new User(2,"zhiran"));
  33.         list.add(new User(3,"zhiran"));
  34.         ModelAndView modelAndView = new ModelAndView("list2");
  35.         modelAndView.addObject("list", list);
  36.         return modelAndView;
  37.     }

  38.     @GetMapping("/map")
  39.     public ModelAndView map() {
  40.         Map user= new HashMap();
  41.         user.put("name", "姓名");
  42.         user.put("sex", "male");
  43.         ModelAndView modelAndView = new ModelAndView("map");
  44.         modelAndView.addObject("map", user);
  45.         return modelAndView;
  46.     }
  47. }
复制代码
上面礼拜闲暇写的thymeleaf的模板引擎类,最简单的那种,全当科普

  1. public class User {
  2.     private long id;
  3.     private String name;

  4.     public long getId() {
  5.         return id;
  6.     }

  7.     public void setId(long id) {
  8.         this.id = id;
  9.     }

  10.     public String getName() {
  11.         return name;
  12.     }

  13.     public void setName(String name) {
  14.         this.name = name;
  15.     }

  16.     public User(long id, String name) {
  17.         this.id = id;
  18.         this.name = name;
  19.     }
  20. }
复制代码
User实体类

孤星11

孤星11 发表于 2022-11-21 22:19:52| 字数 843 | 显示全部楼层

legs+ 发表于 2022-11-18 12:41
那天用golang写一个

我又借用你的题目(钻石)在本地论坛发问,结果有人用Go语言写了一个:


  1. package main

  2. import (
  3.         "fmt"
  4. )

  5. // ASCII codes for asterisk and space
  6. const (
  7.         star  = 42
  8.         space = 32
  9. )

  10. func main() {
  11.         fmt.Println("Height: 10")
  12.         printDiamondH(10)
  13. }

  14. func printDiamondH(h int) {
  15.         if h%2 == 0 {
  16.                 printDiamondW(h + 1)
  17.         } else {
  18.                 printDiamondW(h)
  19.         }
  20. }
  21. func printDiamondW(w int) {
  22.         row := make([]byte, w)
  23.         for i, _ := range row {
  24.                 row[i] = space
  25.         }

  26.         // Starting positions for the star(s)
  27.         l, r := w/2, w/2
  28.         if w%2 == 0 {
  29.                 l = r - 1
  30.         } // When the width is even, the first and last row will have 2 stars instead of 1

  31.         // Grow downward until the middle row
  32.         for l >= 0 && r < len(row) {
  33.                 row[l], row[r] = star, star

  34.                 fmt.Println(string(row))

  35.                 row[l], row[r] = space, space // reset the array

  36.                 l--
  37.                 r++
  38.         }

  39.         // Manually move the pointers so the middle row isn't printed twice
  40.         l = 1
  41.         r = len(row) - 2

  42.         // Shrink it back
  43.         for l <= r {
  44.                 row[l], row[r] = star, star

  45.                 fmt.Println(string(row))

  46.                 row[l], row[r] = space, space // reset the array

  47.                 l++
  48.                 r--
  49.         }
  50. }
复制代码


孤星11

孤星11 发表于 2022-11-21 22:21:03| 字数 102 | 显示全部楼层

legs+ 发表于 2022-11-21 12:19
上面礼拜闲暇写的thymeleaf的模板引擎类,最简单的那种,全当科普

User实体类

我最怕碰到C#,C语言的class,struct, union那些,不会啊。

legs+

legs+ 发表于 2022-11-22 07:21:43| 字数 67 | 显示全部楼层

孤星11 发表于 2022-11-21 22:21
我最怕碰到C#,C语言的class,struct, union那些,不会啊。

c哪有class

孤星11

孤星11 发表于 2022-11-22 10:48:18| 字数 44 来自手机 | 显示全部楼层

legs+ 发表于 2022-11-22 07:21
c哪有class

哦哦,那我错了......

点评

没关系  发表于 2022-11-22 16:50
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则