a question about two internal loops

 

hi all ;

how can i write the following idea :-

1 - i have 100 double variable with names x1 -x2 - x3 ........... x100

2 - i want to subtract x1 -x2 then x1 - x3 then x1 - x4 ........ till x1-x100

3- second loop x2-x3,x2-x4,x2-x5....... x2-x100

4- x3-x4,x3-x5,x3-x6............x3-x100

98 - x95-x96,x95-x97,........x95-x100

99- x99-x100

can anyone helps with my full thanks and respect

 

first of all, use arrays.

then you could simply loop trough

numbers[y]-numbers[x]

from what i understand it may be simple as:

for(int x=0;x<99;x++){
  for(int y=x;y<99;y++){
   numbers[x]-numbers[y];
  }
}
 

I would use

for(int x=0;x<99;x++){
  for(int y=x+1;y<100;y++){
   double diff = numbers[x]-numbers[y];
  }
}

where each array goes from index 0 to 99

(Code just typed[well, copied & changed], not compiled or tested)

 

thanks for all the answers

and sorry for being late

Reason: