第1题
程序代码如下,为完成以上功能,请将第13行标号处缺少的代码填写完整。
A、else if (x == 0)
B、if (x == 0)
C、if (x = 0)
D、else if (x = 0)
第2题
编程计算下面的分段函数,根据从键盘输入的x值,在屏幕上输出y值。按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。#include <stdio.h> #include <math.h> int main() { int x; double y; printf("Input x: "); scanf("%d", &x); // 输入一个整数 if (x > 0) { y = exp(-x); //如果大于0,计算y=exp(-x)的值 } _____________ { y = 1; //x=0,则y=1 } ______________ { y = -exp(x); //x<0,则y=-exp(x) } printf("y="%f\n"," y); return 0;> A、第14行: else if (x == 0) 第20行: else
B、第14行: else if (x = 0) 第20行: else
C、第14行: if (x == 0) 第20行: else
D、第14行: if (x = 0) 第20行: else if (x<0)<br>
第3题
编程计算下面的分段函数,根据从键盘输入的x值,在屏幕上输出y值。按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。#include <stdio.h> #include <math.h> int main() { int x; double y; printf("Input x: "); scanf("%d", &x); // 输入一个整数 if (x > 0) { y = exp(-x); //如果大于0,计算y=exp(-x)的值 } _____________ { y = 1; //x=0,则y=1 } ______________ { y = -exp(x); //x<0,则y=-exp(x) } printf("y="%f\n"," y); return 0;> A、第14行: else if (x == 0) 第20行: else
B、第14行: else if (x = 0) 第20行: else
C、第14行: if (x == 0) 第20行: else
D、第14行: if (x = 0) 第20行: else if (x<0)<br>
第4题
编程计算下面的分段函数,根据从键盘输入的x值,在屏幕上输出y值。按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。#include <stdio.h> #include <math.h> int main() { int x; double y; printf("Input x: "); scanf("%d", &x); // 输入一个整数 if (x > 0) { y = exp(-x); //如果大于0,计算y=exp(-x)的值 } _____________ { y = 1; //x=0,则y=1 } ______________ { y = -exp(x); //x<0,则y=-exp(x) } printf("y="%f\n"," y); return 0;> A、第14行: else if (x == 0) 第20行: else
B、第14行: else if (x = 0) 第20行: else
C、第14行: if (x == 0) 第20行: else
D、第14行: if (x = 0) 第20行: else if (x<0)>
第5题
编程计算下面的分段函数,根据从键盘输入的x值,在屏幕上输出y值。按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。#include <stdio.h> #include <math.h> int main() { int x; double y; printf("Input x: "); scanf("%d", &x); // 输入一个整数 if (x > 0) { y = exp(-x); //如果大于0,计算y=exp(-x)的值 } _____________ { y = 1; //x=0,则y=1 } ______________ { y = -exp(x); //x<0,则y=-exp(x) } printf("y="%f\n"," y); return 0;> A、第14行: else if (x == 0) 第20行: else
B、第14行: else if (x = 0) 第20行: else
C、第14行: if (x == 0) 第20行: else
D、第14行: if (x = 0) 第20行: else if (x<0)>
第6题
编程计算下面的分段函数,根据从键盘输入的x值,在屏幕上输出y值。按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。#include <stdio.h> #include <math.h> int main() { int x; double y; printf("Input x: "); scanf("%d", &x); // 输入一个整数 if (x > 0) { y = exp(-x); //如果大于0,计算y=exp(-x)的值 } _____________ { y = 1; //x=0,则y=1 } ______________ { y = -exp(x); //x<0,则y=-exp(x) } printf("y="%f\n"," y); return 0;> A、第14行: else if (x == 0) 第20行: else
B、第14行: else if (x = 0) 第20行: else
C、第14行: if (x == 0) 第20行: else
D、第14行: if (x = 0) 第20行: else if (x<0)>
第7题
下面程序的功能是从键盘输入10个整数,用函数编程实现计算其最大值和最小值,并互换它们所在数组中的位置。程序运行结果如下: Input n(n<=10):10↙ 0 1 2 3 4 6 7 9 10 input numbers:1 –2 -1 ↙ exchange results: -2 按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 #include> void ReadData(int a[], int n); void PrintData(int a[], int n); void MaxMinExchang(int a[], int n); void Swap(int *x, int *y); int main() { int a[10], n; printf("Input n(n<=10):"); scanf("%d", &n); printf("input %d numbers:", n); readdata(a, maxminexchang(a, printf("exchange results:"); printdata(a, return 0; } * 函数功能:输入数组a的n个元素值 void readdata(int a[], int n) { i; for (i="0;" i i++) &a[i]); 函数功能:输出数组a的n个元素值 printdata(int printf("%5d", a[i]); printf("\n"); 函数功能:将数组a中的最大数与最小数位置互换 maxminexchang(________, maxvalue="a[0]," minvalue="a[0]," maxpos="0," minpos="0;" if (a[i]> maxValue) { maxValue = _______; maxPos = ____; } if (a[i] < minValue) { minValue = a[i]; minPos = i; } } Swap(________________); } /* 函数功能:两整数值互换 */ void Swap(int *x, int *y) { int ________; temp = *x; _________; *y = temp; }
A、第41行: int a[] 第49行: a[i] 第50行: i 第58行: &a[maxPos], &a[minPos] 第64行: temp 第66行: *x = *y
B、第41行: int a 第49行: a[i] 第50行: i 第58行: a[maxPos], a[minPos] 第64行: temp 第66行: *x = *y
C、第41行: int a[] 第49行: a[0] 第50行: 0 第58行: &a[maxPos], &a[minPos] 第64行: *temp 第66行: x = y
D、第41行: int a[] 第49行: a[n-1] 第50行: n-1 第58行: *a[maxPos], *a[minPos] 第64行: &temp 第66行: x = y
第8题
从键盘任意输入一个实数,不使用计算绝对值函数编程计算并输出该实数的绝对值。 按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 #include <stdio.h> int main() { float x; printf("Input a float number:"); scanf("%f", &x); ______________; printf("Absolute value of x is %f\n", x); return 0; }
A、if (x < 0) x = -x
B、x = -x
C、if (x > 0) continue
D、if (x > 0) x = x
第9题
5、编程实现一个输入指定范围内的整数的函数 题目内容: 编程实现一个输入指定范围内的整数的函数getint,其完整的函数原型为:int getint(int min, int max);,它负责接收用户的输入进行验证,保证接收的一定是一个介于min和max之间([min, max]区间内)的一个整数并最后返回该整数。如果用户输入不合法,则会提示继续输入,直到输入合法时为止。要求编写完整的程序并测试你所写的getint函数。 程序的运行结果示例: Please enter min,max: 3,100↙ Please enter an integer [3..100]: -2↙ Please enter an integer [3..100]: 0↙ Please enter an integer [3..100]: 116↙ Please enter an integer [3..100]: 58↙ The integer you have entered is:58 输入提示信息:"Please enter min,max:\n" "Please enter an integer [%d..%d]:\n" 输入格式: 输入数据区间的最小值和最大值:"%d,%d" 输入指定范围内的整数: "%d" 输出格式:"The integer you have entered is:%d\n" 为避免出现格式错误,请直接拷贝粘贴题目中给的格式字符串和提示信息到你的程序中。 题目运行时间限制: 500ms 题目运行内存限制: 32000kb
第10题
下面程序的功能是用函数编程实现两个数组中对应元素值的交换。按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 程序的运行结果示例: Input array size(n<=10):5↙ 1 2 3 4 5 6 7 8 9 10 input array a:1 5↙ b:6 10↙ output a: b: #include> #define N 10 void ReadData(int a[], int n); void PrintData(int a[], int n); void Swap(int *x, int *y); int main() { int a[N], b[N], i, n; printf("Input array size(n<=10):"); scanf("%d", &n); printf("input array a:"); readdata(a, n); b:"); readdata(b, for (i="0;" i i++) { swap(____________); } printf("output printdata(a, printdata(b, return 0; * 函数功能:输入数组a的n个元素值 void readdata(int a[], int n) i; &a[i]); 函数功能:输出数组a的n个元素值 printdata(int printf("%5d", a[i]); printf("\n"); 函数功能:两整数值互换 swap(int *x, *y) temp; ____________;> A、第17行:&a[i], &b[i] 第52行:temp = *x 第53行:*x = *y 第54行:*y = temp
B、第17行:a[i], b[i] 第52行:temp = *x 第53行:*x = *y 第54行:*y = temp
C、第17行:&a[i], &b[i] 第52行:*temp = *x 第53行:*x = *y 第54行:*y = *temp
D、第17行:a[i], b[i] 第52行:temp = x 第53行:x = y 第54行:y = temp
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!