ZZULIOJ 1011~1015 (c++)

1011: 圆柱体表面积

ZZULIOJ 1011~1015 (c++)_第1张图片

#include 
using namespace std;
#define PI 3.14159
int main(){
	double r;
	double h;
	cin>>r>>h;
	double l = 2*PI*r*h;
	double y = PI*r*r;
	//cout<

1012: 求绝对值

ZZULIOJ 1011~1015 (c++)_第2张图片

#include
#include 
using namespace std;
#define PI 3.14159
int main(){
	double n;
	cin>>n;
	if(n>=0){
		cout<
#include 
using namespace std;
#define PI 3.14159
int main(){
	double n;
	cin>>n;
	if(n>=0){
		cout<

1013: 求两点间距离

ZZULIOJ 1011~1015 (c++)_第3张图片

#include
#include 
#include
using namespace std;
int main(){
	double x1,y1;
	double x2,y2;
	cin>>x1>>y1>>x2>>y2;
	double x;
	double y ;
	if(x1>x2){
		x = x1-x2;
	}else{
		x = x2-x1;
	}

	if(y1>y2){
		y = y1-y2;
	}else{
		y = y2-y1;
	}
	
	cout<

1014: 求三角形的面积

ZZULIOJ 1011~1015 (c++)_第4张图片
海伦公式ZZULIOJ 1011~1015 (c++)_第5张图片

#include
#include 
#include
using namespace std;
int main(){
	double a,b,c;
	cin>>a>>b>>c;
	double p =(a+b+c)/2;
	
	cout<

1015: 计算时间间隔

ZZULIOJ 1011~1015 (c++)_第6张图片

不知道为何这道题c++的代码不能通过
附上我没有通过的c++代码(本人觉得没有错误)

#include
#include
using namespace std;
int main(){
    int t1[3] = {0};
    int t2[3] = {0};
    int j=0;
    string s1;
    string s2;
    cin>>s1>>s2;
    char c1[s1.length()];
    char c2[s2.length()];
    strcpy(c1,s1.data());
    strcpy(c2,s2.data());
    for(int i =0;i=t1[2]){
        time = time + t2[2]-t1[2];
    }else{
        t2[1]--;
        time = time +t2[2]+60-t1[2];
    }

    if(t2[1]>=t1[1]){
        time = time + (t2[1]-t1[1])*60;
    }else{
        t2[0]--;
        time = time + (t2[2]+60-t1[2])*60;
    }

    if(t2[0]>=t1[0]){
        time = time + (t2[0]-t1[0])*3600;
    }

    cout<

毕竟复试机试要用c语言,要开始用c了~

c语言这个是通过了测试的

int main(){
    int h1,m1,s1;
    int h2,m2,s2;
    scanf("%d:%d:%d",&h1,&m1,&s1);
    scanf("%d:%d:%d",&h2,&m2,&s2);

    int time = 0;
    if(s2>=s1){
        time = time +s2-s1;
    }else{
        m2--;
        time = time+s2+60-s1;
    }
    if(m2>=m1){
        time = time + (m2-m1)*60;
    }else{
        h2--;
        time = time+ (m2+60-m1)*60;
    }

    if(h2>=h1){
        time = time +(h2-h1)*3600;
    }

    printf("%d",time);

}

你可能感兴趣的:(ZZULIOJ 1011~1015 (c++))