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 A[13], B[18], C[20] susteveni ot realni chisla sys stoinosti v intervala [0; 99.99]. Programata da izvurshi slednite deistviq:\n");
- printf("Da se sviqt masivite A B C posredstvom izkluchvane na nulevite elementi i elementite po - malki ot 5.5\n");
- printf("Trite masiva da se obedinqt v nov masiv D[K, 3] kato svobodnite kletki se zapulnqt s 0\n");
- printf("Avtor: ..........\n");
- int i, x, y, a, b, c, row, col;
- //arrayA
- printf("Vavedi razmer za A ot 1 do 13: ");
- scanf("%d", &a);
- double arrayA[a];
- printf("Vavedi chisla za A: ");
- for (i = 0; i < a; i++){
- scanf("%lf", &arrayA[i]);
- }
- printf("Otpechatvane predi obrabotka: \n" );
- for(i = 0; i < a; i++) {
- printf("%lf\n", arrayA[i]);
- }
- printf("Otpechatvane sled obrabotka: ");
- for (i = 0; i < a; i++){
- if (arrayA[i] > 5.5 && arrayA[i] != 0){
- printf("%lf\n", arrayA[i]);
- }else{
- continue;
- }
- }
- //arrayB
- printf("Vavedi razmer za B ot 1 do 18: ");
- scanf("%d", &b);
- double arrayB[b];
- printf("Vavedi chisla za B: ");
- for (x = 0; x < b; x++){
- scanf("%lf", &arrayB[x]);
- }
- printf("Otpechatvane predi obrabotka: ");
- for(x = 0; x < b; x++) {
- printf("%lf\n", arrayB[x]);
- }
- printf("Otpechatvane sled obrabotka: ");
- for (x = 0; x < b; x++){
- if (arrayB[x] > 5.5 && arrayB[x] != 0){
- printf("%lf\n", arrayB[x]);
- }else{
- continue;
- }
- }
- //arrayC
- printf("Vavedi razmer za C ot 1 do 20: ");
- scanf("%d", &c);
- double arrayC[c];
- printf("Vavedi chisla za C: ");
- for (y = 0; y < c; y++){
- scanf("%lf", &arrayC[y]);
- }
- printf("Otpechatvane predi obrabotka: ");
- for(y = 0; y < 20; y++) {
- printf("%lf\n", arrayC[y]);
- }
- printf("Otpechatvane sled obrabotka: ");
- for (y = 0; y < c; y++){
- if (arrayC[y] > 5.5 && arrayC[y] != 0){
- printf("%lf\n", arrayC[y]);
- }else{
- continue;
- }
- }
- int maxNum = a > b ? (a > c ? a : c) : (b > c ? b : c);
- double D[3][maxNum];
- int count = 1;
- for(row = 0; row < 3; row++){
- if(count > 3) break;
- for(col = 0; col < maxNum; col++){
- switch(row){
- case 0:
- if (arrayA[col] > 5.5){
- D[row][col] = arrayA[col];
- } else {
- D[row][col] = 0;
- }
- break;
- case 1:
- if (arrayB[col] > 5.5){
- D[row][col] = arrayB[col];
- } else {
- D[row][col] = 0;
- }
- break;
- case 2:
- if (arrayC[col] > 5.5){
- D[row][col] = arrayC[col];
- } else {
- D[row][col] = 0;
- }
- break;
- }
- }
- count++;
- }
- count = 1;
- printf("Otpechatvane D: \n");
- for(row = 0; row < 3; row++){
- if(count > 3) break;
- for(col = 0; col < maxNum; col++){
- printf("%lf ", D[row][col]);
- }
- printf("\n");
- count++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement