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 dvumerniq masiv A[N, N], kudeto dannite sa celi chisla v intervala [-10, 10]\n");
- printf("Da se obrazuva ednomeren masiv C, elementite na koito sa elementite ot masiva A, chiito kvadrati sa po - golemi ot 50\n");
- printf("Polucheniqt masiv da se sortira po golemina\n");
- printf("Avtor: Violeta Starcheva\n");
- int n;
- printf("Enter size of the array: ");
- scanf("%d", &n);
- int A[n][n];
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- printf("A[%d][%d] = ", i, j);
- scanf("%d", &A[i][j]);
- }
- }
- printf("---------------\n");
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- printf("A[%d][%d] = %d\n", i, j, A[i][j]);
- }
- }
- int foundElements = 0;
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- if(pow(A[i][j], 2) > 50){
- foundElements++;
- }
- }
- }
- int C[foundElements];
- int index = 0;
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- if(pow(A[i][j], 2) > 50){
- C[index] = A[i][j];
- index++;
- }
- }
- }
- int a;
- for (int i = 0; i < foundElements; ++i)
- {
- for (int j = i + 1; j < foundElements; ++j)
- {
- if (C[i] < C[j])
- {
- a = C[i];
- C[i] = C[j];
- C[j] = a;
- }
- }
- }
- printf("Result:\n");
- for (int i = 0; i < foundElements; ++i)
- {
- printf("%d\n", C[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement