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

相亲网站策划书c++能不能作为网页开发语言

相亲网站策划书,c++能不能作为网页开发语言,火车头wordpress发布图片,网页设计公司申请最近在做java作业, 发现了一个问题, 就是nextline其实会接收缓冲区的\r, 使得在程序运行时nextline像是跳过了一样, 其实不然, 它只是读取了上一个enter时的\r, 如我的如下功能代码 public void run() {Scanner scan new Scanner(System.in);int ord, book_order;int flag 0;…最近在做java作业, 发现了一个问题, 就是nextline其实会接收缓冲区的\r, 使得在程序运行时nextline像是跳过了一样, 其实不然, 它只是读取了上一个enter时的\r, 如我的如下功能代码 public void run() {Scanner scan new Scanner(System.in);int ord, book_order;int flag 0;String isbn new String();String nme new String();while (flag 0) {System.out.println(Function List:);System.out.println(1.Show the book list);System.out.println(2.Find book);System.out.println(3.Add book);System.out.println(4.Delete book);System.out.println(0.Exit);System.out.println(Please input the functon order:);ord scan.nextInt();switch (ord) {case 0: {flag 1;break;}case 1: {Print();break;}case 2: {Scanner in new Scanner(System.in);System.out.println(Please input the ISBN of book you want to find:);isbn in.nextLine();book_order Find(isbn);if (book_order ! 0) {System.out.println(Success!);System.out.println(Name: books[book_order].name);System.out.println(ISBN: books[book_order].ISBN);System.out.println();} else {System.out.println(Error!No such book!);System.out.println();}break;}case 3: {Scanner in new Scanner(System.in);System.out.println(Please input the name of the book:);nme scan.nextLine();System.out.println(Please input the ISBN of the book:);isbn scan.nextLine();if (Add(nme, isbn)) {System.out.println(Add successfully!);System.out.println();} else {System.out.println(Failed to add!Its out of range!);System.out.println();}break;}case 4: {System.out.println(Please input the ISBN of book you want to delete:);isbn scan.nextLine();if (Del(isbn)) {System.out.println(Delete successfully!);System.out.println();} else {System.out.println(Failed to delete!No such book!);System.out.println();}break;}}}scan.close();} }在这里, 我一开始就已经实例化了一个scanner对象, 命名为scan, 然后在输入功能选项时我们调用了nextInt, 那么在输入完之后, 整数被读取进去了, 但是那个\r还留在scan的buffer区域, 所以, 如果我们添加书籍的话, 再次使用scan的nextline来读取书名的话, nextline就会得到scan的buffer区域中的\r,导致程序错误, 所以,在这里看到老师的代码之后, 得到启发, 重新新建一个scanner对象, 在这里可以使用Scanner in, 这样的话, in的buffer区域中就没有之前存留的\n, 那么这个时候我们再输入一行, 则不会出现\r被读取的问题. public void run() {Scanner scan new Scanner(System.in);int ord, book_order;int flag 0;String isbn new String();String nme new String();while (flag 0) {System.out.println(Function List:);System.out.println(1.Show the book list);System.out.println(2.Find book);System.out.println(3.Add book);System.out.println(4.Delete book);System.out.println(0.Exit);System.out.println(Please input the functon order:);ord scan.nextInt();switch (ord) {case 0: {flag 1;break;}case 1: {Print();break;}case 2: {Scanner in new Scanner(System.in);System.out.println(Please input the ISBN of book you want to find:);isbn in.nextLine();book_order Find(isbn);if (book_order ! 0) {System.out.println(Success!);System.out.println(Name: books[book_order].name);System.out.println(ISBN: books[book_order].ISBN);System.out.println();} else {System.out.println(Error!No such book!);System.out.println();}break;}case 3: {Scanner in new Scanner(System.in);System.out.println(Please input the name of the book:);nme in.nextLine();System.out.println(Please input the ISBN of the book:);isbn in.nextLine();if (Add(nme, isbn)) {System.out.println(Add successfully!);System.out.println();} else {System.out.println(Failed to add!Its out of range!);System.out.println();}break;}case 4: {System.out.println(Please input the ISBN of book you want to delete:);isbn scan.nextLine();if (Del(isbn)) {System.out.println(Delete successfully!);System.out.println();} else {System.out.println(Failed to delete!No such book!);System.out.println();}break;}}}scan.close();} }运行结果如下: 此外, 也可以和cpp一样, 使用一次scan.nextLine将那个\r读取.
http://www.pierceye.com/news/272707/

相关文章:

  • 青岛网站制作排名绵阳做网站优化
  • 扬州市建设工程造价管理站网站开发建设网站
  • 广州网站设计公司济南兴田德润o评价潍坊响应式网站建设要多久
  • 网站模板如何优化平阳县建设局网站
  • 厦门外贸网站找谁可以做app的网站
  • 本地电脑静态网站建设游戏代理平台免费
  • 网站建设公司的成本有哪些内容wordpress admin空白
  • 高端网站建设如何收费济南行业网站建设
  • 昆明网站制作专业麦当劳订餐网站 是谁做的
  • 网站代备案公司名称网页游戏怎么搭建
  • 教师在哪些网站可以做兼职做平面的公司网站
  • php网站后台程序做游戏ppt下载网站有哪些
  • 柳州正规网站制作公司佛山企业名录黄页
  • 企业网站做备案网站换域名 百度收录
  • 平面网站模版网站建设需要的费用
  • 营销型网站案例展示如何做网赌网站
  • 商融交通建设工程有限公司网站wordpress的伪静太文件
  • 网站rar文件做sorry动图的网站
  • 有合作社做网站得不备案期间关网站吗
  • 南京城乡住房建设厅网站wordpress文章模板下载
  • 有一个做搞笑英语视频网站外贸建站优化
  • 苏州公司建设网站深圳品牌蛋糕店有哪些品牌排行
  • 手机网站建设视频教程、网站建设项目功能需求分析报告
  • 纸 技术支持 东莞网站建设wordpress 手机 自建站
  • 网站后台 搜索广告发布合同模板
  • 手机网站设计教程网站建设 职位
  • 外贸网站图片素材谷歌seo和百度seo区别
  • 龙华网站 建设深圳信科潍坊网站建设培训
  • 域名网站平台qq在线登录
  • 成都做网站建设公司网站建设公司销售技巧