Need to make a program:

Find all the elements of the one-dimensional array M (15) that are before its minimum element, write to the array M1, and the others to M2

Closed due to the fact that off-topic participants Yura Ivanov , Timofei Bondarev , Athari , dlarchikov , Mirdin 2 May '15 at 7:45 .

  • Most likely, this question does not correspond to the subject of Stack Overflow in Russian, according to the rules described in the certificate .
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
  • @toris, According to the rules of the forum, questions should not be reduced to the decision or the completion of student assignments. Please clarify what you have done yourself and what did not work out. - Nicolas Chabanovsky ♦
  • four
    I vote for the closure of this issue as not relevant topic, work for the author. - Yura Ivanov

3 answers 3

for (i=0; i<25; i++){ if (m[i]<x){ m1[] = m[i]; } else{ m2[] = m[i]; } } 
  • Can I please complete the listing of the program - toris
  • @KARTOH. Not less, but EARLY! - BuilderC
  • If x is the index of the minimum element, then it is correct. But from this piece of code that x is not clear, because there is no code for finding the minimum element. Another m1 [] = m [i] and m2 [] = [i] is the record where? - insolor
  • Please write the full listing of the program - toris
 #include <stdio.h> #include <stdlib.h> void main() { int m[15],m1[15],m2[15]; int i,imin,min; // Π·Π°ΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ массива ΠΌ случайными числами ΠΎΡ‚ 0 Π΄ΠΎ 99: for(i=0;i<15;i++) { m[i]=rand()%100; printf("%d ",m[i]); } printf("\n"); // Поиск минимального элСмСнта: imin=0; // здСсь Π±ΡƒΠ΄Π΅Ρ‚ индСкс минимального элСмСнта min=m[0]; // здСсь Π±ΡƒΠ΄Π΅Ρ‚ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ минимального элСмСнта for(i=1;i<15;i++) if(m[i]<min) { imin=i; min=m[i]; } // ΠšΠΎΠΏΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ всСх элСмСнтов Π΄ΠΎ минимального Π² массив m1: for(i=0;i<imin;i++) { m1[i]=m[i]; printf("%d ",m1[i]); } printf("\n"); // ΠšΠΎΠΏΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ всСх ΠΎΡΡ‚Π°Π»ΡŒΠ½Ρ‹Ρ… элСмСнтов Π² массив m2: for(i=imin;i<15;i++) { m2[i-imin]=m[i]; printf("%d ",m2[i-imin]); } } 
     #include<stdlib.h> int main() { const int L = 15; int M[L], M1[L], M2[L]; int Min = 99, Imin; randomize(); for(int i = 0; i < L; i++) { M[i] = random(100); if(M[i] < Min) { Min = M[i]; Imin = i; } } for(int i = 0, j = 0, k = 0; i < L; i++) if(i < Imin] M1[j++] = M[i]; else M2[k++] = M[i]; return 0; }