zoukankan      html  css  js  c++  java
  • 参考代码1021-1031

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 int main()
     4 {
     5     double c; 
     6     int a,b;
     7     cin>>a>>b;
     8     c=sqrt(a*a+b*b);
     9     printf("%.1lf
    ",c);
    10     return 0;
    11 }

    1022 两点距离

     1 #include <bits/stdc++.h>           
     2 using namespace std;                
     3 int main()                      
     4 {   
     5     double x1,y1,x2,y2,d;
     6     cin>>x1>>y1>>x2>>y2;//注意输入顺序和输入个数 
     7     d=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
     8     d=sqrt(d);
     9     printf("%.2lf
    ",d);
    10     return 0;
    11   } 

    1023 绝对值

     1 #include <bits/stdc++.h>           
     2 using namespace std;                
     3 int main()                      
     4 {   
     5     int a;
     6     double b;
     7     cin>>a>>b;
     8     a=abs(a);
     9     b=fabs(b);
    10     cout<<a<<" "<<b<<endl; 
    11     return 0;
    12   }

     1024 天花板和地板函数

    1 #include <bits/stdc++.h>           
    2 using namespace std;                
    3 int main()                      
    4 {   
    5     double x;
    6     cin>>x;
    7     cout<<ceil(x)<<" "<<floor(x)<<endl; 
    8     return 0;
    9   } 

    1025 求平方根

     1 #include <bits/stdc++.h>           
     2 using namespace std;                
     3 int main()                      
     4 {   
     5     double x,y;
     6     cin>>x;
     7     y=sqrt(x);
     8 //    cout<<fixed<<setprecision(3)<<y<<endl;
     9     printf("%.3lf
    ",y);
    10     return 0;
    11   } 

    1026 n的a次方

     1 #include <bits/stdc++.h>           
     2 using namespace std;                
     3 int main()                      
     4 {   
     5     int n,a;
     6     long long c;
     7     cin>>n>>a;
     8     c=pow(n,a);
     9     cout<<c<<endl;
    10     return 0;
    11   } 

    1027: 与圆相关的计算

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 int main()
     4 {
     5     double r;
     6     double zj,zc,mj;  //分别表示直径,周长,面积 
     7     const double pi=3.14159; 
     8     cin>>r;
     9     zj=2*r;
    10     zc=2*pi*r;
    11     mj=pi*r*r;
    12     printf("%.4lf %.4lf %.4lf
    ",zj,zc,mj) ;
    13     return 0;
    14 } 

    1028: 球体体积

     1 #include <bits/stdc++.h>           
     2 using namespace std;                
     3 int main()                      
     4 {   
     5     double r,v;
     6     const double PI=3.1415927;
     7     cin>>r;
     8     v=4.0/3*PI*r*r*r;
     9     printf("%.3lf",v);
    10     return 0;
    11   } 

    1029: 计算曼哈顿距离

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 main()
     4 {
     5     double x1,y1,x2,y2,d;
     6     cin>>x1>>y1>>x2>>y2;
     7     d=fabs(x2-x1)+fabs(y2-y1); 
     8     printf("%.3lf
    ",d);
     9     return 0;
    10  } 

    1030: 特殊输出

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 main()
     4 {
     5     int x,y;
     6     cin>>x>>y;
     7     printf("%*d
    ",y,x);
     8     printf("%0*d
    ",y,x);
     9     printf("%-*d
    ",y,x);
    10     return 0;
    11  } 

    1031: 实数格式化输出

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 main()
     4 {
     5     double x;
     6     int    y;  //表示场宽 
     7     cin>>x>>y;
     8     printf("%*.3lf
    ",y,x);
     9     printf("%0*.3lf
    ",y,x);
    10     printf("%-*.3lf
    ",y,x);
    11     return 0;
    12  } 
  • 相关阅读:
    李航统计学习方法(第二版)(六):k 近邻算法实现(kd树(kd tree)方法)
    ActiveMQ的安装和启动
    HTML select autofocus 属性
    macpath (File & Directory Access) – Python 中文开发手册
    Java Bitset类
    Linux zip命令
    HTML DOM Keygen 对象
    tanh (Numerics) – C 中文开发手册
    no-shadow (Rules) – Eslint 中文开发手册
    require-await (Rules) – Eslint 中文开发手册
  • 原文地址:https://www.cnblogs.com/pythen/p/11684807.html
Copyright © 2011-2022 走看看