当前位置: 首页 > news >正文

建电子商城网站杨凌网站建设哪家好

建电子商城网站,杨凌网站建设哪家好,wordpress 添加设置方法,wordpress wp_page_menu生命游戏其实是一个零玩家游戏#xff0c;它包括一个二维矩形世界#xff0c;这个世界中的每个方格居住着一个活着的或死了的细胞。一个细胞在下一个时刻生死取决于相邻八个方格中活着的或死了的细胞的数量。如果相邻方格活着的细胞数量过多#xff0c;这个细胞会因为资源匮…生命游戏其实是一个零玩家游戏它包括一个二维矩形世界这个世界中的每个方格居住着一个活着的或死了的细胞。一个细胞在下一个时刻生死取决于相邻八个方格中活着的或死了的细胞的数量。如果相邻方格活着的细胞数量过多这个细胞会因为资源匮乏而在下一个时刻死去相反如果周围活细胞过少这个细胞会因太孤单而死去。 具体规则如下 1如果一个细胞周围有3个细胞为生一个细胞周围共有8个细胞则该细胞为生即该细胞若原先为死则转为生若原先为生则保持不变 。 2 如果一个细胞周围有2个细胞为生则该细胞的生死状态保持不变 3 在其它情况下该细胞为死即该细胞若原先为生则转为死若原先为死则保持不变 在程序中使用0代表死1代表生。 串行模式 public class lifegame {public static ListString readTxt(String fileName){ListString listnew ArrayList();try { // 防止文件建立或读取失败用catch捕捉错误并打印也可以throw/* 读入TXT文件 */File filename new File(fileName); // 要读取以上路径的input。txt文件InputStreamReader reader new InputStreamReader(new FileInputStream(filename)); // 建立一个输入流对象readerBufferedReader br new BufferedReader(reader); // 建立一个对象它把文件内容转成计算机能读懂的语言String line ;line br.readLine();while (line ! null) {list.add(line);line br.readLine();}} catch (Exception e) {e.printStackTrace();}return list;}public static void writeTxt(String content){try { // 防止文件建立或读取失败用catch捕捉错误并打印也可以throw/* 读入TXT文件 */File writename new File(output.txt); // 相对路径如果没有则要建立一个新的output。txt文件writename.createNewFile(); // 创建新文件BufferedWriter out new BufferedWriter(new FileWriter(writename));out.write(content); // \r\n即为换行out.flush(); // 把缓存区内容压入文件out.close(); // 最后记得关闭文件} catch (Exception e) {e.printStackTrace();}}public boolean[][] world;public int len;int times;public lifegame(ListString list) {int nInteger.parseInt(list.get(0));worldnew boolean[n][n];this.lenn;this.timesInteger.parseInt(list.get(1));System.out.println(len);for(int i2;ilist.size();i){String[] templist.get(i).split(,);int xInteger.parseInt(temp[0]),yInteger.parseInt(temp[1]);world[x][y]true;}System.out.println(list.get(0)times);}public void print(){for(int i0;ilen;i){for(int j0;jlen;j)if(world[i][j])System.out.print(1);else System.out.print(0);System.out.println();}System.out.println();}private int[][] dirnew int[][]{{0,1},{0,-1},{1,0},{-1,0},{1,1},{-1,-1},{-1,1},{1,-1}};public void change(){int[][] countnew int[len][len];for(int i0;ilen;i)for(int j0;jlen;j)count[i][j]count(i,j);for(int i0;ilen;i)for(int j0;jlen;j)if(count[i][j]3){world[i][j]true;}else if(count[i][j]!2)world[i][j]false;}public int count(int x,int y){int ret0;for(int[] c:dir){int nextXc[0]x,nextYc[1]y;if(nextX0nextXlennextY0nextYlen){retworld[nextX][nextY]?1:0;}}return ret;}public static void main(String[] args){lifegame onnew lifegame(readTxt(input.txt));for(int i0;ion.times;i){on.change();}StringBuilder stringBuildernew StringBuilder();for(int i0;ion.len;i)for(int j0;jon.len;j){if(on.world[i][j]){stringBuilder.append(i).append(,).append(j).append(\r\n);}}writeTxt(stringBuilder.toString());} } 并行模式 public class lifegame2 {public static ListString readTxt(String fileName){ListString listnew ArrayList();try { // 防止文件建立或读取失败用catch捕捉错误并打印也可以throw/* 读入TXT文件 */File filename new File(fileName); // 要读取以上路径的input。txt文件InputStreamReader reader new InputStreamReader(new FileInputStream(filename)); // 建立一个输入流对象readerBufferedReader br new BufferedReader(reader); // 建立一个对象它把文件内容转成计算机能读懂的语言String line ;line br.readLine();while (line ! null) {list.add(line);line br.readLine();}} catch (Exception e) {e.printStackTrace();}return list;}public static void writeTxt(String content){try { // 防止文件建立或读取失败用catch捕捉错误并打印也可以throw/* 读入TXT文件 */File writename new File(output.txt); // 相对路径如果没有则要建立一个新的output。txt文件writename.createNewFile(); // 创建新文件BufferedWriter out new BufferedWriter(new FileWriter(writename));out.write(content); // \r\n即为换行out.flush(); // 把缓存区内容压入文件out.close(); // 最后记得关闭文件} catch (Exception e) {e.printStackTrace();}}int[][] count;private boolean[][] world;int len;public int times;public int getTimes() {return times;}public lifegame2(ListString list) {int nInteger.parseInt(list.get(0));worldnew boolean[n][n];countnew int[n][n];this.lenn;this.timesInteger.parseInt(list.get(1));System.out.println(len);for(int i2;ilist.size();i){String[] templist.get(i).split(,);int xInteger.parseInt(temp[0]),yInteger.parseInt(temp[1]);world[x][y]true;}System.out.println(list.get(0)times);}public void print(){for(int i0;ilen;i){for(int j0;jlen;j)if(world[i][j])System.out.print(1);else System.out.print(0);System.out.println();}System.out.println();}public String excute(int c){ExecutorService executorService Executors.newFixedThreadPool(c);for(int j0;jtimes;j){CountDownLatch countDownLatchnew CountDownLatch(c);Thread[] threads new Thread[10];for(int i0;ilen;ilen/c){excuteThread curnew excuteThread(count,i,ilen/c-1,world,countDownLatch);executorService.execute(cur);}try {countDownLatch.await();} catch (InterruptedException e) {e.printStackTrace();}for(int i0;ilen;i)for(int k0;klen;k)if(count[i][k]3){world[i][k]true;}else if(count[i][k]!2)world[i][k]false;System.out.printf(第%d轮结束\n,j);}executorService.shutdown();while (!executorService.isTerminated()){}StringBuilder stringBuildernew StringBuilder();for(int i0;ilen;i)for(int j0;jlen;j){if(world[i][j]){stringBuilder.append(i).append(,).append(j).append(\r\n);}}return stringBuilder.toString();}public static void main(String[] args){lifegame2 onnew lifegame2(readTxt(input.txt));long sSystem.currentTimeMillis();String ton.excute(4);System.out.println(((double) (System.currentTimeMillis()-s))/1000);writeTxt(t);} } public class excuteThread implements Runnable{int[][] count;int l,r,len;boolean[][] world;CountDownLatch countDownLatch;public excuteThread(int [][] count,int l,int r,boolean[][] world,CountDownLatch countDownLatch) {lencount.length;this.countcount;this.ll;this.rr;this.countDownLatchcountDownLatch;this.worldworld;}Overridepublic void run() {System.out.println(线程l*4/len开始);for(int i0;ilen;i)for(int jl;jr;j)count[i][j]count(i,j);System.out.println(线程l*4/len结束);countDownLatch.countDown();}private int[][] dirnew int[][]{{0,1},{0,-1},{1,0},{-1,0},{1,1},{-1,-1},{-1,1},{1,-1}};public int count(int x,int y){int ret0;for(int[] c:dir){int nextXc[0]x,nextYc[1]y;if(nextX0nextXlennextY0nextYlen){retworld[nextX][nextY]?1:0;}}return ret;} }
http://www.pierceye.com/news/191000/

相关文章:

  • 甜品店网站开发背景江宁区住房建设局网站
  • asp.net网站开发视频教程找能做网站的
  • 租房合同范本下载word东莞网络优化
  • 做网站需要会写代码6net快速建站
  • 克拉玛依 网站建设红圈工程项目管理软件
  • 北京网站ui设计公司共青城网站建设公司
  • 电子商务网站设计说明书开发一个网站
  • 网站制作长沙怎么做淘客手机网站
  • 五路居网站建设wordpress php允许上传文件大小
  • 旅游网站的设计代码下列哪些不属于企业网站建设基本原则
  • 房屋租赁网站开发意义做男鞋的网站
  • 网站负责人可以备案北京建设部网站 信息中心
  • 网站建设分录怎么开四川省城乡住房建设部网站首页
  • 刘家窑网站建设公司如何在网络上推广产品
  • 全球建站东莞市的网站公司哪家好
  • 地方网站发展怎么做链接推广产品
  • 上海制造网站公司网站优化做网站优化
  • vs2012做网站wordpress 页眉
  • 北网站建设重庆建设工程查询网站
  • 给我做网站的人老是给我留点尾巴太原本地网站搭建公司
  • 静态页面网站站标代码写进到静态页面了 怎么不显示呢?自助建站网
  • 免费在线代理网站微信会员卡管理系统
  • 和动物做的网站吗做网站销售怎么样
  • 宝塔面板做织梦网站深圳龙华大浪做网站公司
  • 阿里云建网站费用上海网站建设觉策动力
  • 电子商务网站的建设与维护方法h5第三方收款平台
  • 网站建设所需人力设计广告网站
  • php网站发送邮件动态倒计时网站模板
  • 温州建设网站制作wordpress调用文章简介
  • 大庆市建设局网站刘东科技公司做网站