Jun 7, 2017 at 2:14am UTC
The swapThree () function swaps three integers a, b, c to b, c, a. Immediately after calling this function, variable a has the value of variable b, b has the value of c, and c has the value of a.
You need to write swapThree () so that main () runs through tests.
Input Description
1 22 3
Output Description
22 3
Last edited on Jun 7, 2017 at 4:11am UTC
Jun 7, 2017 at 2:44am UTC
void swapThree(int &a, int &b, int &c0)//
int t = a;//
a = b;//
b = t;//
int d = b;//
b = c;//
b = d;//
}
Jun 7, 2017 at 2:56am UTC
cout sai rin oi
cout ra 22 1 3 :(
Jun 7, 2017 at 3:00am UTC
thoi toi fix duoc roi
phai la
void swapThree(int &a, int &b, int &c){
int t = a;
a = b;
b = t;
int d = b;
b = c;
c = d;
}
Jun 7, 2017 at 3:17am UTC
viet lai ho bai 2 100/100 voi
Jun 7, 2017 at 3:46am UTC
bai struct 4
struct Student{
string name;
double math, physics, chemistry;
Student(string _name){
name = _name;
}
void setMarks(double a, double b, double c){
math = a;
physics = b;
chemistry = c;
}
string getName(){
return name;
}
double getAverage(){
return (math + physics + chemistry) / 3;
}
};
Jun 7, 2017 at 3:54am UTC
i'm sure the forum would appreciate if you guys can restrict your public correspondence to English. thanks
Jun 7, 2017 at 3:58am UTC
number 2
#include <iostream>//
#include <cmath>//
using namespace std;//
int main(){//
int n;//
cin >> n;//
int a[n];//
for(int i = 0; i < n; i++){//
cin >> a[i];
}
int min = abs(a[0] - a[1]);
for(int i = 0; i < n - 1; i++){
for(int j = i + 1; j < n; j++){
if( abs(a[i] - a[j]) < min )
min = abs( a[i] - a[j] );
}
}
cout << min;
}