佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1206|回复: 6

[pro]C++ programming的朋友,请进来!谢谢!

[复制链接]
发表于 28-12-2012 03:37 PM | 显示全部楼层 |阅读模式
各位网友们,
                 我有个问题关于C++ Programming下请教一下,问题如下;
                 Assume that array X contains 10 integers.
                 (i) Write the function definition for doubleValue, that receives the array X as input parameter, multiplies the value of each array element by 2 and displays the new contents of array X.

如果会的,请回复我,小弟感激不尽!!
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 28-12-2012 03:47 PM | 显示全部楼层
Is my answer correct?

void double(int * x){
          y = x * 2;
}

printf("%d", &y);


Please provide me your comment if you found any wrong/mistake, thanks alot!! ^^
回复

使用道具 举报

发表于 28-12-2012 03:53 PM | 显示全部楼层

void doubleValue(int input[]){
    for(int i=0; i<10; i++){
        input[i] *= 2;
        printf("input[%d] = %d", i, input[i]);
    }
}

很久没碰C++了,加上没有visual C++来run。所以有问题就自行debug吧。
回复

使用道具 举报

 楼主| 发表于 28-12-2012 04:10 PM | 显示全部楼层
哦,好的,谢谢!!可是在program里面没看见有什么output喔!!
回复

使用道具 举报

 楼主| 发表于 28-12-2012 05:59 PM | 显示全部楼层
and this is the 2nd question,
write a function definition for getData to prompt and read the customer's current balance (currentBal) in RM and the total minutes (totalMin) of phone calls from the user. The function will return the customer's current balance and output the total minutes via a reference parameter.

请问有哪位C++ Programming 会做这题?可以帮小弟回答一下?多谢!!!
回复

使用道具 举报

发表于 6-1-2013 02:20 PM | 显示全部楼层
modern c++ 用vector不用array.  
回复

使用道具 举报

Follow Us
发表于 26-1-2013 11:54 PM | 显示全部楼层
gksean123 发表于 28-12-2012 05:59 PM
and this is the 2nd question,
write a function definition for getData to prompt and read the custo ...

int getData( int currentBal, int *totalMin ){
cout << "Please insert customer's current balance and total minutes of phone call" << endl;
cin >> currentBal >> *totalMin;
return currentBal;
};


不要嫌弃,我也不是pro,还在college学习罢了。
btw,我相信楼主已经解决问题了,只是路过看到想要试试看这个题目罢了,不懂对不对?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 20-5-2024 02:05 PM , Processed in 0.104229 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表