C++学习记录NO.2

 #顺序结构

#include <iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int sn=(1+n)*n/2;
    cout << sn << endl;
    return 0;
}

#include <iostream>
using namespace std;
int main()
{
    char c1='C',c2='h',c3='i',c4='n',c5='a';
    cin>>c1>>c2>>c3>>c4>>c5;
    c1=c1+4;c2=c2+4;c3=c3+4;c4=c4+4;c5=c5+4;
    cout << c1<<c2<<c3<<c4<<c5<< endl;
    return 0;
}

 

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    double x1,y1,x2,y2,x3,y3;
    cin>>x1>>y1>>x2>>y2>>x3>>y3;
    double S=(x3*y2+x2*y1+x1*y3-x1*y2-x2*y3-x3*y1)*0.5;
    cout <<fixed<<setprecision(2)<<S<< endl;
    return 0;
}

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    double r1,r2,r;
    cin>>r1>>r2;
    r=r1*r2/(r1+r2);
    cout <<fixed<<setprecision(2)<<r<< endl;
    return 0;
}

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    int a,b,c,d,x,h,m;
    char ch;
    cin>>a>>ch>>b>>c>>ch>>d;
    x=c*60+d-a*60-b;
    m=x%60;
    h=(x-m)/60;
    cout <<h<<"时"<<m<<"分"<< endl;
    return 0;
}

#include <iostream>
#include<cmath>    //ceil头文件
using namespace std;
#define PI 3.1415926535
int main()
{
    double h,r;
    cin>>h>>r;
    double v=PI*r*r*h;
    double water=20000;
    int n=ceil(water/v); 
    cout << n << endl;
    return 0;
}

#include <iostream>
#include <iomanip>
#include <cmath>
#define PI 3.141592653
using namespace std;
int main()
{
    double n,x;
    cin>>n;
    x=n*PI/180;
    cout <<fixed <<setprecision(2)<<sin(x)<<" "<<cos(x) << endl;
    return 0;
}

#include <iostream>
using namespace std;
int main()
{
    int n;
    std::cin>>n;
    int a0,a1,a2;
    a0=n%10;
    a1=(n/10)%10;
    a2=(n/100)%10;
    std::cout << a0<<a1<<a2 << endl;
    return 0;
}

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int a,b,z,n;
    cin>>a>>b;
    z=a*10+b;
    int price=19;
    n=floor(z/price);
    cout << n<< endl;
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
int main()
{
    double F,c;
    scanf("%lf",&F);
    c=5*(F-32)/9.0;
    printf("c=%.2lf\n",c); 
    return 0;
}

  • 20
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值