郑州轻工业oj1000~1049

该博客汇总了一系列C语言基础编程题,包括整数运算、数列求和、几何计算、条件判断等。涉及pow()、sqrt()等函数使用,还包含闰年判断、字符转换等内容,适合C语言初学者练习。

1000: 从今天开始入坑C语言

ZZULIOJ

#include<iostream>
using namespace std;

int main(){
   
   
	
	cout<<"从今天开始入坑C语言";
	return 0;
} 

1001: 整数a+b

ZZULIOJ

#include<iostream>

using namespace std;

int main(){
   
   
	int a,b;
	cin>>a>>b;
	cout<<a+b<<endl;
	return 0;
}

##1002: 简单多项式求值

ZZULIOJ

#include<iostream>
using namespace std;

int main(){
   
   
	int x;
	cin>>x;
	cout<<2*x*x+x+8;
	return 0;
}

1003: 两个整数的四则运算

ZZULIOJ

#include<iostream>

using namespace std;

int main(){
   
   
	int a,b;
	cin>>a>>b;
	cout<<a+b<<" "<<a-b<<" "<<a*b<<" "<<a/b<<" "<<a%b<<endl;
	
}

1004: 三位数的数位分离

ZZULIOJ

#include<iostream>

using namespace std;

int main(){
   
   
	int x;
	cin>>x;
	cout<<x%10<<" "<<(x/10)%10<<" "<<x/100<<endl;
	 
	return 0;
}

1005: 整数幂

ZZULIOJ

pow()函数

#include<iostream>
#include<cmath>
using namespace std;

int main(){
   
   

int a,b,c;
cin>>a>>b>>c;

printf("%-9d%-9d%-9d\n",a,a*a,a*a*a);
printf("%-9d%-9d%-9d\n",b,b*b,b*b*b);
printf("%-9d%-9d%-9d\n",c,c*c,c*c*c);
	
}

1006: 求等差数列的和

ZZULIOJ

#include<iostream>

using namespace std;
int main(){
   
   
	int a,b,c;
	cin>>a>>b>>c;
	int sum = 0;
	for(int i = a;i<=b;i = i +c){
   
   
		sum+=i;
	}
	cout<<sum;
	return 0;
}

1007: 鸡兔同笼

ZZULIOJ

#include<iostream>
using namespace std;
int main(){
   
   
	int a,b;
	cin>>a>>b;
	//假设都是兔子  应该有a*4脚 ,但是只有b个脚,插值就是 鸡假冒兔子少的脚
	int x = 0,y =0;//x鸡  y兔
	x = (a*4 - b )/2;
	y =a - x;
	cout<<x<<" "<<y<<endl;
	return 0;
}

1008: 美元和人民币

ZZULIOJ

#include<iostream>
using namespace std;

int main(){
   
   
	double a;
	cin>>a;
	printf("%.2lf",a*6.5573);
}

1009: 求平均分

ZZULIOJ

#include<iostream>
using namespace std;
int main(){
   
   
	double a,b,c;
	cin>>a>>b>>c;
	printf("%.2lf",(a+b+c)/3);
	return 0;
} 

1010: 求圆的周长和面积

ZZULIOJ

#include<iostream>

const double PI = 3.14159;
using namespace std;
int main(){
   
   
	double r;
	cin>>r;
	printf("%.2lf %.2lf",2*PI*r,PI*r*r);
	return 0;
	
}

1011: 圆柱体表面积

ZZULIOJ

#include<iostream>
#define PI 3.14159
using namespace std;
int main(){
   
   
	double r,h;
	cin>>r>>h;
	printf("%.2lf",2*PI*r*r+2*r*PI*h);
	return 0;
}

1012: 求绝对值

ZZULIOJ

#include<iostream>

using namespace std;
int main(){
   
   
	double x;
	cin>>x;
	if(x<0){
   
   
		x = -x;
	}
	printf("%.2lf",x);
	return 0;
}

1013: 求两点间距离

ZZULIOJ

sqrt()函数

#include<iostream>
#include<cmath>
using namespace std;
int main(){
   
   
	double x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	printf("%.2lf",sqrt((x1-x2)*(x1-x2) +(y1-y2)*(y1-y2))); 
	return 0;
	
}

1014: 求三角形的面积

ZZULIOJ

任意三角形的面积公式(海伦公式):S^2=p(p-a)(p-b)(p-c), p=(a+b+c)/2, a,b,c为三角形三边。

#include<iostream>
#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值