2018江苏大学885 编程题

0b03c43e7e241c53006849f7347b704ca80.jpg

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define N 11
float fun(float a, float b, float c){
	float t;
	t = (4.25*(a+b)+log(a+b+sqrt(a+b)+1.0/(a+b)))/(4.25*c+log(c+sqrt(c)+1.0/c));
	return t;
}
int main(){
	float a[11],b[11],c[11];
	int i;
	float t;
	for(i = 1; i < N; i++){
		scanf("%f%f%f",&a[i],&b[i],&c[i]);
	} 
	FILE *fp;
	if((fp = fopen("data.txt","w+"))==NULL){
		printf("cannot open this file\n");
		exit(0);
	}
	for(i = 1; i < N; i++){
		t = fun(a[i],b[i],c[i]);
		printf("a=%f,b=%f,c=%f,T=%f\n",a[i],b[i],c[i],t);
		fprintf(fp,"a=%f,b=%f,c=%f,T=%f\n",a[i],b[i],c[i],t);
	}
	fclose(fp);
	return 0;
}

 

52e04455a527a6ae34c890aef9ce624275e.jpg

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
int main(){
	long m,n;
	int i = 0,count = 0,flag=0;
	int a[100];
	scanf("%ld",&m);
	n = m;
	while(n){			//如果m是降序数,那么数组从0开始是从小到大 
		a[i] = n % 10;
		n /= 10;
		i++;
		count++;
	}
	for(i = 0;i < count-1; i++){		//count-1 防止数组越界 
		if(a[i] > a[i+1]){				//当m是个位数时,跳过这个循环,直接输出降序数 
			flag = 1;
			printf("%d不是降序数\n",m);
			break;
		}
	}
	if(!flag){							
		printf("%d是降序数\n",m);
	}
	return 0;
}

 

aca2423e7e809cf48df40472bd0a7af87cf.jpg

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double f(double x){
	return pow(x,41)+pow(x,3)+1;
}
double fd(double x){
	return 41*pow(x,40)+3*pow(x,2);
}
int main(){
	double x = -1.0;
	/*
	float x2;					// 作两次差 
	x2 = x - f(x)/fd(x);
	while(fabs(x2-x)>1e-6){
		x = x2;
		x2 = x-f(x)/fd(x);
	}
	printf("%f\n",x2);
	*/
	while(fabs(f(x)/fd(x))>1e-6){		// 直接公式右侧fdao移到左侧就能看到两次结果之差 
		x = x-f(x)/fd(x);
	}
	printf("%f",x);
	return 0;
}
//-0.952484

 

转载于:https://my.oschina.net/timebear/blog/2987022

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值