自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(14)
  • 收藏
  • 关注

原创 PTA 7-1 计算圆柱体的体积

#include<stdio.h>double cylinder (double r,double h);int main(){ double n, m; scanf("%lf %lf",&n,&m); printf("Volume = %.3lf",cylinder(n,m));}double cylinder (double r,double h){ double i = 3.141592,v; v = i * r*r*h; return...

2022-03-29 21:59:16 2455 1

原创 PTA 6-10 使用函数求余弦函数的近似值

double funcos( double e, double x ){ double i = 0, j, k = 0, h = 1, m = 1, p ,sum = 0,n; while(fabs(h)>= e) { p = 1; for(i = 1;i <= k; i++) { p = i*p; } n = pow(x,k); h = fabs(n) / p * m; m = -m; sum = su...

2022-03-29 21:57:16 376

原创 PTA 6-3 使用函数求1到10的阶乘和

double fact( int n ){ static m = 1; m = m*n; return m;}

2022-03-29 21:56:09 1180 1

原创 PTA 6-2 符号函数

int sign( int x ){ int n, m; if(x < 0) { m = -1; } else if(x == 0) { m = 0; } else { m = 1; } return m;}

2022-03-29 21:53:52 389

原创 PTA 6-1 使用函数计算两点间的距离

double dist( double x1, double y1, double x2, double y2 ){ double h, i, j; i = fabs(x1 - x2); j = fabs(y1 - y2); h = sqrt(i*i+j*j); return h; }

2022-03-25 18:40:02 1814

原创 PTA -- 判断一个整数是否为素数

#include<stdio.h> #include<math.h> int main() { int N, a, b,i; scanf("%d",&N); if(N == 1) // 将1和2 单独提出 { printf("No"); } else if(N == 2) { printf("Yes"); } else if(N <= 0) // N <= 0 时都不是素数 ...

2021-12-03 18:36:46 886

原创 PTA -- 统计一个整数的位数

第一种方法:比较难以理解#include<stdio.h>#include<math.h>int main(){ int i,N,a,count = 0; scanf("%d",&N); if(N != 0 && fabs(N) <= pow(10,9)) { for(i = 1;i <= 10;i++) { if(N / 10.0 != 0) .

2021-12-03 18:16:40 1710 1

原创 PTA-- 实验4-1-10 兔子繁衍问题

#include<stdio.h>int main(){ int N,x1 = 1,x2 = 1,sum = 1,month = 2; scanf("%d",&N); if(N == 1) { printf("1"); } else { while(sum < N) { month++; sum = x1+x2; x1 = x2; x2 = sum; } printf("%d",month);...

2021-12-02 18:07:01 1837 1

原创 PTA-- 实验3-1 求一元二次方程的根

#include<stdio.h>#include<math.h>int main(){ //定义变量 double a, b, c, x1, x2, x3, A; //输入数字 scanf("%lf %lf %lf",&a, &b, &c); //算式计算 A = b*b - 4*a*c; x1 = ( -b + pow( A, 1.0/2.0) )/ (2*a); x2 = ( -b - pow(A, 1.0...

2021-12-02 15:22:12 1003

原创 PTA 计算华氏温度

#include<stdio.h>int main(){ int celsius = 26, fahr; fahr = 9*celsius/5+32; printf("celsius = 26, fahr = %d",fahr); return 0;}

2021-11-30 19:50:57 668

原创 PTA 求整数均值

#include<stdio.h>int main(){ int a,b,c,f,Sum; double Average; scanf("%d %d %d %d",&a, &b ,&c,&f); Sum=a+b+c+f; Average=Sum/4.0; printf("Sum = %d; Average = %.1lf",Sum,Average); return 0;}

2021-11-30 19:48:56 1299

原创 PTA 计算摄氏温度

#include<stdio.h>int main(){ int fahr,celsius; scanf("%d",&fahr); celsius=5*(fahr-32)/9; printf("Celsius = %d",celsius); return 0;}

2021-11-30 19:47:05 213

原创 PTA 温度转换

#include<stdio.h>int main(void){ int fahr,celsius; fahr=150; celsius=5*(fahr-32)/9; printf("fahr = 150, celsius = %d",celsius); return 0;}

2021-11-30 19:44:24 643

原创 PTA-7-2 简单的猜数字游戏【2】

#include<stdio.h> int main(){ int n, a, b,count = 0,i; scanf("%d",&n); for(i = 1;i <= 7; i++) { scanf("%d",&a); if(a == n) { printf("Lucky You!"); break; } else if(a > n) { printf("Too big\n"); count++.

2021-11-30 13:43:32 1422 1

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除