+ 5

I need help . Write a complete c++program in which you have array.ar [5]={1, 6, 8, 9, 7}. In which user choose 3numbers from the

array and the program finds all the rest random sets of 3 numbers and all must be in the range of the array

18th Dec 2016, 3:28 PM
F.Heeh. 2nd Yr. Hebron University‏‎
F.Heeh. 2nd Yr. Hebron University‏‎ - avatar
2 Respuestas
+ 5
this is the solution but need improvements.if u can, pleas tell me how to improve it
18th Dec 2016, 3:34 PM
F.Heeh. 2nd Yr. Hebron University‏‎
F.Heeh. 2nd Yr. Hebron University‏‎ - avatar
+ 5
#include <iostream> #include<cmath> using namespace std; int main() { //int a[3]={1,2,3}; //for(int i=0;i<3;i++){ //for(int j=0;j<3;j++){ // if(a[i]==a[j])continue; // cout<<a[i]<<a[j]<<endl; // } // } //return 0; //} int a[8]={1,2,3,4,5,6,7,8}; for(int i1=0;i1<8;i1++){ for(int i2=0;i2<8;i2++){ for(int i3=0;i3<8;i3++){ for(int i4=0;i4<8;i4++){ for(int i5=0;i5<8;i5++){ for(int i6=0;i6<8;i6++){ if(a[i1]==a[i2]||a[i1]==a[i3]||a[i1]==a[i4]||a[i1]==a[i5]||a[i1]==a[i6])continue; if(a[i2]==a[i3]||a[i2]==a[i4]||a[i2]==a[i5]||a[i2]==a[i6])continue; if(a[i3]==a[i4]||a[i3]==a[i5]||a[i3]==a[i6])continue; if(a[i4]==a[i5]||a[i4]==a[i6])continue; if(a[i5]==a[i6])continue; cout<<"("<<a[i1]<< a[i2]<<a[i3]<<a[i4]<<a[i5]<<a[i6]<<")"; } } } } } } return 0; }
18th Dec 2016, 3:35 PM
F.Heeh. 2nd Yr. Hebron University‏‎
F.Heeh. 2nd Yr. Hebron University‏‎ - avatar