关于一道根据键盘输入一串数组,经过换算得到另一串数组的程序

来源:百度知道 编辑:UC知道 时间:2024/05/22 17:11:22
小弟对这道题目没有头绪,恳请高手指教,不知道从何处下手。谢谢@!

A series of numbers can be read from the keyboard and put into an array of integers. You will then need to call a function to invert the values (1/x) and put the inverted valued into a new array of doubles.

Write the pseudocode (algorithm) for the following program definition: Write a program to read an integer count (between 1 and 10) and then read count integer values to put into the array. For each value, call the inveritng function and put the inverting value into the second array of doubles. Finally print out a report in two lines and count +1 columns to display the original and the inverted values and the largest value of each array in squared brackets.

You must use arrays and you must use a function in this program.

Typical result:
Original values: 4 5 100 [100]
Inverted values: 0.25 0.20 0.01 [0.25]
简单的说,就是从键盘读入一串数字(INT),存入数组,将每个值进行固定的运算(取倒数),然后将结果(DOUBLE)放入第2行数字,讲这两行数

int func(double *des,int *src,int len){
while(len--){
(*des++)=(double)(1.0/(*src++));
}
return 0;
}
int int_max(int *array,int len){
int i;
int max;
max=*array;
while(len--){
max=*array++>max?*array:max;
}
return max;
}
double的类似,然后自己写一个main吧

应你的邀请,我再帮你写一个main...
如题意,不需要你自己输入,而是从1到10
int main(){
int i;
int a[10];
double b[10];
for(i=1;i!=11;++i){//给a数组付值
a[i-1]=i;
}
func(b,a,10);?//给b数组付值
for(i=0;i!=10;++i)
printf("%d ",a[i]);
printf("[%d]\n",int_max(a,10));
for(i=0;i!=10;++i)
printf("%f ",b[i]);
//printf("[%f]\n",double_max(a,10));这个函数没写,注释掉这行以便编译~
return 0;
}
这样整个程序就差double_max()没写了,再写就写完了...你自己捉摸一下吧。

本来想看看能不能帮你的,看到英语头都晕了。