Need help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Need help

there are two arrays. one array, for example, with dimensions 7.1, 7.56, 7.34, 7.23, 8.89, 9.1. the second array consists of numbers from 7 to 11, with a step of 0.01. it is necessary that in the second array, with a step of 0.16, a unit is displayed if the number is contained in the interval 7 to 7.16, if it is not contained, 0 is displayed For example: [7, 7.16] 1 [7.17, 7.33] 0 Dunno how to use cycles right in this case

16th Apr 2022, 7:55 PM
Nik
Nik - avatar
5 Answers
+ 1
Show your code you tried
16th Apr 2022, 8:54 PM
Jackie
Jackie - avatar
+ 1
static double[] xtao(int t1; int t2; double[] tk) double[] mas = new double mas[1000]; int count = 0; for (double i = (double) t1; i <= (double)t2; i+= 0.01) { mas[count] = i; count++; } for (int n = 0; n < mas.Length; n++) { for(double j = (double) t1; j <= (double)t2; j+= 0.16) { if(mas.Contains(tk[n])) {mas[n] = 1;} else { mas[n] = 0;} } } i know that it's not right and it's wrong to write that way but it was my last try from today. Have no idea what to do here anymore
16th Apr 2022, 9:20 PM
Nik
Nik - avatar
0
And the input values?
16th Apr 2022, 9:21 PM
Jackie
Jackie - avatar
0
Random numbers t1 = 7, t2 = 11 double[] tk between 7 and 11
16th Apr 2022, 9:24 PM
Nik
Nik - avatar
0
Random numbers in in the interval 7 and 11
16th Apr 2022, 9:25 PM
Nik
Nik - avatar