日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

2018年江苏大学885代码题(含答案)

發(fā)布時(shí)間:2024/3/24 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 2018年江苏大学885代码题(含答案) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

2018年江蘇大學(xué)885代碼題

  • 一、前言
  • 二、正文
    • 1.第一題
    • 2. 第二題
    • 3.第三題

一、前言

提示:以下是博主自己寫的代碼,僅供參考,歡迎有興趣的朋友們留言討論呀

二、正文

1.第一題

#include<stdio.h> #include<stdlib.h> #include<math.h>#define N 10// 函數(shù)計(jì)算 double FT(double a, double b, double c);void main() {double a[N], b[N], c[N];int i;FILE* fp;// 打開或創(chuàng)建文件if (!(fp = fopen("data.txt", "a+"))){printf("cannot open the file!\n");exit(0);}// 輸入數(shù)據(jù)for (i = 0; i < N; i++){printf("請輸入第%d組a,b,c:", i + 1);scanf("%lf%lf%lf", &a[i], &b[i], &c[i]);printf("\n");}// 計(jì)算,保存和顯示結(jié)果for (i = 0; i < N; i++){printf("a=%.2lf,b=%.2lf,c=%.2lf,T=%lf\n", a[i], b[i], c[i], FT(a[i], b[i], c[i]));fprintf(fp,"a=%.2lf,b=%.2lf,c=%.2lf,T=%lf\n", a[i], b[i], c[i], FT(a[i], b[i], c[i]));}// 關(guān)閉文件if (fclose(fp)){printf("cannot close the file!\n");} }double FT(double a, double b, double c) {double up, down;up = 4.25 * (a + b) + log(a + b + sqrt(a + b) + 1 / (a + b));down = 4.25 * c + log(c + sqrt(c) + 1 / c);return up / down; }

運(yùn)行結(jié)果示例:


驗(yàn)算結(jié)果:
時(shí)間問題,只驗(yàn)算了一組數(shù)據(jù)(3,4,5)
手寫版:

2. 第二題

#include<stdio.h>// 判斷一個(gè)自然數(shù)是否是降序數(shù),是則返回1,否則返回0 int judge(long int num);void main() {long int num;while (1){printf("請輸入一個(gè)自然數(shù):\n");scanf("%d", &num);if (num >= 0) {break;}}if (judge(num)){printf("%ld是降序數(shù)\n", num);}else{printf("%ld不是降序數(shù)\n", num);} }int judge(long int num) {int l, r = 0;if (num < 10){return 1;}else{while (num){l = num % 10;if (l < r){return 0;}r = l;num /= 10;}}return 1; }

運(yùn)行結(jié)果示例:



手寫版:

3.第三題

#include<stdio.h> #include<math.h>// 原函數(shù) double F(double x); // 導(dǎo)數(shù) double G(double x);void main() {double x = -1, y;do {y = x;x = y - F(y) / G(y);} while (fabs(x - y) > 1e-6);printf("方程的近似根為:%lf\n", x); }double F(double x) {return pow(x, 41) + x * x * x + 1; }double G(double x) {return 41 * pow(x, 40) + 3 * x * x; }

運(yùn)行結(jié)果示例:

手寫版:

→返回總目錄

總結(jié)

以上是生活随笔為你收集整理的2018年江苏大学885代码题(含答案)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。