這是原來代碼中的多個參數:C++與CIN
#include <iostream>
using namespace std;
int addNumbers(int x, int y, int z, int a) {
int result = x + y + z + a;
return result;
}
int main()
{
cout << addNumbers(1, 7, 8, 3);
return 0;
}
,我只是測試我的代碼:
#include <iostream>
using namespace std;
int addNumbers(int x, int y, int z, int a) {
int result = x + y + z + a;
return result;
}
int main() {
int x,y,z,a;
int result = x + y + z + a;
cin >> result;
return 0;
}
林用C只是新++,我想知道是否有可能使用的輸入(cin)在(x,y,z,a)變量內添加一個值並使用result = x + y + z + a來添加它;
目前尚不清楚你想要做什麼。你能否詳細說明一下? –
首先,這段代碼不會編譯,因爲你沒有定義變量x,y,z,一個 – shofee
原始代碼x,y,z,a在int main()中有它們自己的值..我試圖改變該場景通過應用cin(輸入4個數字然後添加它) – Chipshot