三次作业总结

第一题

import java.util.Scanner;
public class Main
{
    public static void main(String[] args)
    {
        int a=0,b=0,c=0,d=0,g=0;
        double x1=0,y1=0,x2=0,y2=0,changdu=0;
        Scanner input=new Scanner(System.in);
        String s=input.nextLine();
        String array[]=s.split(" ");
        for(a=0;a<array.length;a++)
        {
            String array1[]=array[a].split(",");
            for(g=0;g<array1.length;g++)
            {
            for(b=0;b<array1[g].length();b++)
            {
                if(array1[g].charAt(b)=='+'||array1[g].charAt(b)=='-')
                {
                    c=c+1;
                }
            }
            if(c>2)
            {
                System.out.println("Wrong Format");
                break;
            }
            c=0;
            }
            if(c>2)
                break;
        }
        if(c<=2)
        {
            if(array.length>2)
            {
                System.out.println("wrong number of points");
            }
            else
            {
                for(b=0;b<array[0].length();b++)
                {
                    if(array[0].charAt(b)==',')
                    {
                        x1=Double.parseDouble(array[0].substring(0,b));
                        y1=Double.parseDouble(array[0].substring(b+1,array[0].length()));
                    }
                }
                for(d=0;d<array[1].length();d++)
                    {
                        if(array[1].charAt(d)==',')
                        {
                            x2=Double.parseDouble(array[1].substring(0,d));
                            y2=Double.parseDouble(array[1].substring(d+1,array[1].length()));
                        }
                    }
                changdu=Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
                System.out.print(changdu);
            }
        }
    }
}

 

第三题

import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        String str = input.nextLine();
        int sum = str.length();
        int count = 0;
        double[] a = new double[2];
        double[] b = new double[2];
        double[] c = new double[2];
        double[] d = new double[2];
        double[] e = new double[2];
        switch(str.charAt(0)){
            case '1':{
                if(str.charAt(1) == ':'){
                    String str1 = str.substring(2);
                    String[] sa = str1.split(" ");
                    for(int i = 0;i < sum;i++){
                        if(str.charAt(i) == ' '){
                            count++;
                        }
                    }
                    if(count != 2){
                        System.out.println("wrong number of points");
                        break;
                    }
                    String[] sb = sa[0].split(",");
                    String[] sc = sa[1].split(",");
                    String[] sd = sa[2].split(",");
                    for(int i = 0;i < 2;i++){
                        a[i] = Double.parseDouble(sb[i]);
                        b[i] = Double.parseDouble(sc[i]);
                        c[i] = Double.parseDouble(sd[i]);
                    }
                    double xab = b[0] - a[0];
                    double xac = c[0] - a[0];
                    double xbc = c[0] - b[0];
                    double yab = b[1] - a[1];
                    double yac = c[1] - a[1];
                    double ybc = c[1] - b[1];
                    double ab = Math.sqrt(xab * xab + yab * yab);
                    double ac = Math.sqrt(xac * xac + yac * yac);
                    double bc = Math.sqrt(xbc * xbc + ybc * ybc);
                    if(ab == 0 || ac == 0 || bc == 0){
                        System.out.println("data error");
                        break;
                    }
                    else{
                        if(a[0] import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        String str = input.nextLine();
        int sum = str.length();
        int count = 0;
        double[] a = new double[2];
        double[] b = new double[2];
        double[] c = new double[2];
        double[] d = new double[2];
        double[] e = new double[2];
        switch(str.charAt(0)){
            case '1':{
                if(str.charAt(1) == ':'){
                    String str1 = str.substring(2);
                    String[] sa = str1.split(" ");
                    for(int i = 0;i < sum;i++){
                        if(str.charAt(i) == ' '){
                            count++;
                        }
                    }
                    if(count != 2){
                        System.out.println("wrong number of points");
                        break;
                    }
                    String[] sb = sa[0].split(",");
                    String[] sc = sa[1].split(",");
                    String[] sd = sa[2].split(",");
                    for(int i = 0;i < 2;i++){
                        a[i] = Double.parseDouble(sb[i]);
                        b[i] = Double.parseDouble(sc[i]);
                        c[i] = Double.parseDouble(sd[i]);
                    }
                    double xab = b[0] - a[0];
                    double xac = c[0] - a[0];
                    double xbc = c[0] - b[0];
                    double yab = b[1] - a[1];
                    double yac = c[1] - a[1];
                    double ybc = c[1] - b[1];
                    double ab = Math.sqrt(xab * xab + yab * yab);
                    double ac = Math.sqrt(xac * xac + yac * yac);
                    double bc = Math.sqrt(xbc * xbc + ybc * ybc);
                    if(ab == 0 || ac == 0 || bc == 0){
                        System.out.println("data error");
                        break;
                    }
                    else{
                        if(a[0] 

实在是想不出有什么好总结的,毕竟现在我对java是啥都不懂,不过一想到这是我发的第一篇博客,难免还是会有一些激动,不过内心还是会有一丝失落和惭愧,源于我第一次发博客是为了应付性的交作业。第一篇发的博客,我还是希望它能反应出我现阶段的生活状态和人生态度,供以后再回首看这篇博客时回忆和感悟。所以我要把我现阶段最喜欢的一首歌的歌词打下来,让它伴随着我的第一篇博客一起发出。

把青春献给身后那座辉煌的都市

为了这个美梦我们付出着代价

把爱情留给我身边最真心的姑娘

你陪我歌唱你陪我流浪

陪我两败俱伤

一直到现在才突然明白我梦寐以求

是真爱和自由

想带上你私奔

奔向最遥远城镇

想带上你私奔

去做最幸福的人

在熟悉的异乡我将自己一年年流放

穿过鲜花走过荆棘只为自由之地

在欲望的城市你就是我最后的信仰

洁白如一道喜乐的光芒将我心照亮

不要再悲伤

我看到了希望

你是否还有勇气 随着我离去

想带上你私奔

奔向最遥远城镇

想带上你私奔

去做最幸福的人

带上你私奔

带上你私奔

posted @ 2022-04-11 11:16  让烟丝燃一会  阅读(43)  评论(0)    收藏  举报