zoukankan      html  css  js  c++  java
  • 第二周星期天

    1.第一个程序 输出helloworld

    package qwert;

    public class A {

    public static void main(String[] args) {
    System.out.println("helloworld");
    // TODO Auto-generated method stub

    }

    }

    第二个程序 自动售货机 根据视频定义了类 创造了对象 调用了方法 实现了输入金额 找零的功能

    package qwert;

    public class M01_Vendingmachine {
    int price=80;
    int balance;
    int total;
    void showPrompt() {
    System.out.println("welcome");
    }
    void insertmoney(int amount) {
    balance=balance+amount;
    }
    void showbalance() {
    System.out.println(balance);
    }
    void getfood() {
    if( balance>=price) {
    System.out.println("here you ara");
    balance=balance-price;
    total=total+price;

    }
    }


    public static void main(String[] args) {
    // TODO Auto-generated method stub
    M01_Vendingmachine vm=new M01_Vendingmachine();
    vm.showPrompt();
    vm.showbalance();
    vm.insertmoney(100);
    vm.getfood();
    vm.showbalance();
    }

    输出显示 投入100块  商品价格80块剩余20块

    welcome
    0
    here you ara
    20

    至此对类和对象方法的用法有了一个实践

    找到了一个dijkstra最短路径算法java实现的教学视频

    https://www.bilibili.com/video/av49271881?from=search&seid=5762113972925241582

    开始观看并学习并跟着写代码

    明确了问题条件与输出

    理解了基本的算法过程

    开始学习具体的代码实现

    public class M02_Dijkstra {

    public static void main(String[] args) {
    // TODO Auto-generated method stub
    int n,m//n个点m条边
    Scanner cin=new Scanner(System.in)
    n=cin.nextInt();
    m=cin.nextInt();
    int value[][]=new int[n+1][n+1];//一个数组?存放ab的路径长度
    for(int i=1;i<=n;i++) {
    for(int j=1;j<=n;j++) {
    value[i][j] =Interger.MAX_VALUE;
    }
    }

    2.问题从头创建类运行程序时找不到,无法运行,

    JAVA错误: 找不到或无法加载主类

    只能在之前的java项目里创建类,不知道什么情况,打算有时间问老师,数组存放内容一开始没有理解,后来自己推出来了

    3.计划明天继续学习dijkstra算法的代码,理解该类的功能,完成写入点的代码和进一步的操作

  • 相关阅读:
    tensorflow笔记(四)之MNIST手写识别系列一
    tensorflow笔记(三)之 tensorboard的使用
    tensorflow笔记(二)之构造一个简单的神经网络
    tensorflow笔记(一)之基础知识
    Andrew Ng机器学习课程笔记(六)之 机器学习系统的设计
    Andrew Ng机器学习课程笔记(五)之应用机器学习的建议
    POJ题目分类
    codeforces 355A Vasya and Digital Root
    ubuntu清理系统垃圾与备份
    poj 1742 Coins (多重背包)
  • 原文地址:https://www.cnblogs.com/pekey/p/11443503.html
Copyright © 2011-2022 走看看