zoukankan      html  css  js  c++  java
  • 结构-03. 平面向量加法(10)

    本题要求编写程序,计算两个二维平面向量的和向量。

    输入格式:

    输入在一行中按照“x1 y1 x2 y2”的格式给出两个二维平面向量V1=(x1, y1)和V2=(x2, y2)的分量。

    输出格式:

    在一行中按照“(x, y)”的格式输出和向量,坐标输出小数点后1位(注意不能输出-0.0)。

    输入样例:

    3.5 -2.7 -13.9 8.7
    

    输出样例:

    (-10.4, 6.0)
     1 #include <stdio.h>
     2 #include <stdlib.h>
     3 #include <iostream>
     4 #include <string.h>
     5 #include <string>
     6 #include <math.h>
     7 
     8 
     9 using namespace::std; 
    10 
    11 int main(){
    12     char s[100];
    13     gets(s);
    14     //划分
    15 
    16     double a,b,c,d;
    17     sscanf(s,"%lf %lf %lf %lf",&a,&b,&c,&d);
    18     double m=a+c,n=b+d;
    19     if(m>-0.05&&m<=0)m=0.0;
    20     if(n>-0.05&&n<=0)n=0.0;
    21     printf("(%.1f, %.1f)",m,n);
    22    
    23     
    24     
    25     return 0;
    26 }
  • 相关阅读:
    SQL 运算符
    Shiro 入门
    SSM 整合配置
    MyBatis 入门
    Git 常用命令
    JSP
    Servlet
    Oracle 基础
    JDBC
    Java Thread
  • 原文地址:https://www.cnblogs.com/ligen/p/4293614.html
Copyright © 2011-2022 走看看