当前位置: 首页 > 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.zqtcl.cn/news/191000/

相关文章:

  • 南昌招商网站建设临沂兰山建设局网站
  • 母婴网站建设怎么样可以做网站
  • 二手车 网站开发wordpress 定时 检查
  • 淮南官网济南seo优化外包
  • 沈阳网站建设莫道网络网站建设常用六大布局
  • 网站建设外文版要求网站关键字优化销售
  • 马来西亚做公路投标网站设计网页多少钱
  • 织梦网站多少钱广告多的网站
  • 济南网站建站模板深圳南园网站建设
  • 国家免费技能培训官网白杨seo博客
  • 福州seo网站建设微服务网站
  • 网站宽度 像素长沙电商运营培训
  • 备案上个人网站和企业网站的区别app开发多少钱一个
  • 有限公司网站建设 中企动力佛山培训机构招生方案
  • 扫黄打非网站建设专业的高端网站制作公司
  • 做自媒体发视频用哪些网站江西网站建设哪家好
  • wordpress用户列表南宁百度seo排名优化
  • 做网站时如何写接口文档上海网站设计建设公司
  • 网站小图标怎么制作平面设计素材网站推荐
  • 多元网络兰州网站建设惠州网页建站模板
  • 网站建设中首页模板下载网页制作模板保存
  • 宁夏做网站的江苏网站建设的案例展示
  • 网站功能需求文档如何免费域名注册
  • 推广网站的软件包头移动的网站建设
  • 自己制作音乐的软件免费上海seo怎么优化
  • 学vue可以做pc网站网站站长统计怎么弄
  • 做物流的可以在那些网站找客户大淘客网站建设app
  • 石家庄兼职做网站dedecms做视频网站
  • 优化公司怎么优化网站的网站 意义
  • 唯品会一家专门做特卖的网站手机版招聘网站开发技术维护