我试图找到以下代码的输出。 如何在magicTime中添加return语句? 输出应该是 a:10 b:30 c: a:10 b:30
#include <iostream>
using namespace std;
int magicTime(int a, int &b, const int &c){
a=c;
b=20;
}
int main(){
int a = 10;
int b = 30;
int c;
cout << "a: " << a << " b " << b << " c " << c << endl;
c=b;
magicTime(c, b, a);
cout << "a: " << a << " b " << b << " c " << c << endl;
return 0 ;
}
答案 0 :(得分:-1)
好的,所以你想要返回一个int
数组伪代码
int[] magicTime(int a, int &b, const int &c){
a=c;
b=20;
return new int [] { a, b, c};
}