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 masiva A[N,N], kudeto dannite sa realni chisla v intervala [-1000;1000]. Programata da izvurshi slednite deistviq:\n");
- printf("Da se obrazuva ednomeren masiv C, elementite na koito sa elementite ot masiva A v zadaden interval [K - L]\n");
- printf("Polucheniqt masiv da se sortira po golemina\n");
- printf("Avtor: ..........\n");
- int n;
- printf("Vavedi golemina na A: ");
- scanf("%d", &n);
- double A[n][n];
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- printf("A[%d][%d] = ", i, j);
- scanf("%lf", &A[i][j]);
- }
- }
- printf("---------------\n");
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- printf("A[%d][%d] = %lf\n", i, j, A[i][j]);
- }
- }
- double k, l;
- int count = 0;
- printf("Vavedi K: ");
- scanf("%lf", &k);
- printf("Vavedi L: ");
- scanf("%lf", &l);
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- if(A[i][j] >= k && A[i][j] <= l){
- count++;
- }
- }
- }
- double C[count];
- int index = 0;
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- if(A[i][j] >= k && A[i][j] <= l){
- C[index] = A[i][j];
- index++;
- }
- }
- }
- printf("Rezultati: \n");
- printf("A)\n");
- for(int i = 0; i < n; i++){
- printf("C[%d] = %lf\n", i, C[i]);
- }
- int a;
- for (int i = 0; i < count; ++i)
- {
- for (int j = i + 1; j < count; ++j)
- {
- if (C[i] < C[j])
- {
- a = C[i];
- C[i] = C[j];
- C[j] = a;
- }
- }
- }
- printf("B)\n");
- for(int i = 0; i < n; i++){
- printf("C[%d] = %lf\n", i, C[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement