新手c语言求教

1.Writetwoseparatevoidfunctions:onevoidfunctioncallit“initialized”andthesecondfunctio... 1. Write two separate void functions: one void functioncall it “initialized” and the second function call it “print”.
A.Inside your initialized void function, you will need to pass the list array andsize as a formal parameters. Within this functions body, you will need to initializea variable called count as intdatatype. Initialize the array so that the first 25 components are equal to thesquare of the index variables. The second 25 components are equal to three times the index variable. Thethird 25 components are equal to fourtimes the index variable. The last 25 components are equal to five times the index variable.

B.In regards to the print void function, you will need to pass the list array andsize as a formal parameters. Output the array so the 10 elements per line areprinted. This function requires you to create ten columns with set width of 5positions. Please use the appropriate commands and pre-processor library filesfor this alignment.

2. Write your function prototypes for the two functions.

3. Inside the main function, write a C++ programming thatdeclares an array alpha of 100components of type double, then callthe both the functions and pass the appropriate parameters.

得出的答案应该是这样的:

万分感激
展开
 我来答
黑帝斯反击
2015-05-08 · TA获得超过152个赞
知道小有建树答主
回答量:120
采纳率:100%
帮助的人:73.6万
展开全部
#include <iostream>
#include <iomanip>
using namespace std;

void initialized(double array[],int size){
int count;
for(count=0;count<size;count++){
if(count<25)
array[count]=count*count;
else if(count<50)
array[count]=3*count;
else if(count<75)
array[count]=4*count;
else
array[count]=5*count;

}


void print(double array[],int size){
int i;
for(i=0;i<size;i++){
cout<<setw(5)<<array[i];
if((i+1)%10==0)
cout<<endl;
}
}

int main(){
double alpha[100];
initialized(alpha,100);
print(alpha,100);
return 0;
}
更多追问追答
追问
感谢,在问一下,第二和三的答案有包括在里面吗,还是你只回答了第一题?
追答
包含全部的
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式