c语言,C++练习,openjudge

hello world!

#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
{
    cout<<"Hello, World!"<<endl;
    system("pause");
    return 0;
}

计算表达式的值

#include <iostream>
#include <stdlib.h>
#include <math.h>
#define pi 3.1415926
using namespace std;
int main()
{
cout<<sin(30*pi/180)*cos(75*pi/180)+log(7.4)+pow(5.6,4)<<endl;
cout<<exp(6)-log10(65)+3*tan(33*pi/180)<<endl;
return 0;
}

A+B Problem

#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout<<a+b<<endl;
return 0;
}

字符三角形

#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
char o;
cin>>o;
printf("%c\n%c%c\n%c%c%c\n%c%c%c%c\n",o,o,o,o,o,o,o,o,o,o);
return 0;
}

二次函数的计算

#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main()
{
float x;
cin>>x;
cout<<3*x*x+6*x-7<<endl;
return 0;
}

欢迎来到C++的世界

#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main()
{
string stuName;
cin>>stuName;
cout<<stuName<<",welcome to C++ world!"<<endl;
return 0;
}

打印钻石图形

#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main()
{
cout<<"   *"<<endl;
cout<<"  ***"<<endl;
cout<<" *****"<<endl;
cout<<"*******"<<endl;
cout<<" *****"<<endl;
cout<<"  ***"<<endl;
cout<<"   *"<<endl;
return 0;
}

计算一元二次方程的根

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
using namespace std;
int main()
{
double a,b,c,x1,x2;
cin>>a>>b>>c;
x1=(-b+sqrt(b*b-4*a*c))/(2*a);
x2=(-b-sqrt(b*b-4*a*c))/(2*a);
cout<<"x1="<<x1<<" x2="<<x2<<endl;
system("pause");
return 0;
}

统计总人数

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,s=0;
	for (int i=0;i<8;i++)
	{
		cin>>n;
		s+=n;
	}	    
	cout<<s<<endl;
	system("pause");
	return 0;
}

计算表达式的值

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
using namespace std;
int main()
{
float x,y;
cin>>x>>y;
cout<<2*x+5-y<<endl;
system("pause");
return 0;
}

计算圆的面积和周长

#include <iostream>
#include <stdio.h>
#include <math.h>
#include<stdlib.h>
#define pi 3.1415926
using namespace std;
int main()
{
float r;
cin>>r;
cout<<pi*r*r<<endl;
cout<<2*pi*r<<endl;
system("pause");
return 0;
}

求四位数的的数字和平方(2)

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
using namespace std;
int main()
{
int n,a,b,c,d;
cin>>n;
a=n%10;
n=n/10;
b=n%10;
n=n/10;
c=n%10;
d=n/10;
cout<<a*a+b*b+c*c+d*d<<endl;
system("pause");
return 0;
}

苹果和虫子

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
using namespace std;
int main()
{
int n,x,y;
cin>>n>>x>>y;
cout<<n-ceil(y*1.0/x)<<endl;
system("pause");
return 0;
}

简单求和

#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main()
{
int n;
cin>>n;
cout<<n*(n+1)/2<<endl;
system("pause");
return 0;
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

阿南不知道

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值