Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main()
- {
- printf("Da se sustavi programa za obrabotka na masivite M1[10], M2[15], M3[20] sustaveni ot celi chisla sus stoinosti v intervala [0; 999]. Programata da izvurshi slednite deistviq:\n");
- printf("Namirane na nomerata na elementite v ednomeren masiv, po - golemi ot chisloto M i po - malki ot sumata na predshestvashtite elementi.\n");
- printf("Avtor: ..........\n");
- int M1[10], M2[15], M3[20];
- int M4[45];
- for(int i = 0; i < 10; i++){
- printf("M1[%d] = ", i);
- scanf("%d", &M1[i]);
- }
- for(int i = 0; i < 15; i++){
- printf("M2[%d] = ", i);
- scanf("%d", &M2[i]);
- }
- for(int i = 0; i < 20; i++){
- printf("M3[%d] = ", i);
- scanf("%d", &M3[i]);
- }
- for(int i = 0; i < 45; i++){
- M4[i] = -1;
- }
- printf("----------------\n");
- for(int i = 0; i < 10; i++){
- printf("M1[%d] = %d\n", i, M1[i]);
- }
- for(int i = 0; i < 15; i++){
- printf("M2[%d] = %d\n", i, M2[i]);;
- }
- for(int i = 0; i < 20; i++){
- printf("M3[%d] = %d\n", i, M3[i]);
- }
- int m;
- printf("---------------\n");
- printf("M = ");
- scanf("%d", &m);
- //printf("M1 Rezultat: \n");
- for(int i = 2; i < 10; i++){
- if(M1[i] > m && M1[i-2] + M1[i-1] > M1[i]){
- //printf("Chislo: %d, Index: %d\n", M1[i], i);
- M4[i] = i + 1;
- }
- }
- //printf("M2 Rezultat: \n");
- for(int i = 2; i < 15; i++){
- if(M2[i] > m && M2[i-2] + M2[i-1] > M2[i]){
- //printf("Chislo: %d, Index: %d\n", M2[i], i);
- M4[i+9] = i + 1;
- }
- }
- //printf("M3 Rezultat: \n");
- for(int i = 2; i < 20; i++){
- if(M3[i] > m && M3[i-2] + M3[i-1] > M3[i]){
- //printf("Chislo: %d, Index: %d\n", M3[i], i);
- M4[i+24] = i + 1;
- }
- }
- // Printirame nomerata na elementite
- for(int i = 0; i < 45; i++){
- if(i == 0){
- printf("\nM1: \n");
- } else if (i == 9) {
- printf("\nM2: \n");
- } else if (i == 24){
- printf("\nM3: \n");
- }
- if(M4[i] != -1){
- printf(" %d", M4[i]);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement