Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
1.24/5 (5 votes)
See more:
1. Write a program to generate a vector of size n entered from the keyboard, with random integers in the interval: k - w, then form two new vectors, the first one with primes ordered in increasing form and the other with ordered non-prime numbers in a decreasing way.

28. For any n generate
Example for n = 5:
9	8	7	6	5
16	15	14	13	4
21	20	19	12	3
24	23	18	11	2
25	22	17	10	1


79. Generate a matrix of size NF * NC, with random integers between zero and one hundred, then separate the perfect ones first, then the non-perfect ones, by columns from bottom to top and from left to right.

92. Generate a matrix of size n, with random numbers, then add a new column and a new row, in these new spaces, obtain the number of primes per rows, the number of non-primes per columns and the number of perfects in the main diagonal
Example for n = 5:

6	16	20	23	25	1
70	12	17	21	24	1
4	8	13	18	22	1
2	51	97	28	19	4
1	3	11	10	15	2
4	3	1	4	4	2


What I have tried:

C++
#include <iostream>
using namespace std;
void listaMatriz(int m[][50], int n){
	int f,c;
	cout << endl << "listado " << endl;
	for(f=0;f<n;f++){
       for(c="0;c<n;c++){
          cout << "\t" << m[f][c];
       }
     endl;
   }
}

void efila(int m[][50], int f, int n, int *e){
   int c, et=*e;
   for (c=0; c < n-(f+1); c++){
      m[f][c]=et;
      et++;
      *e=et;
   }

void ecolumna(int fi;
   c=n-(f+1);
   (fi=f; fi < n; fi++){
      m[fi][c]=et;
      escuadras(int m[][50], n){
      f,e=1;
      (f=0; f< n; f++){
         efila(m,f,n,&e);
         ecolumna(m,f,n,&e);
      }
   }

int main(int argc, char *argv[]) {
   m[50][50];
   n="10;
   escuadras(m,n);
   listamatriz(m,n);
   return="" 0;
}
Posted
Updated 27-Oct-21 20:05pm
v4
Comments
jeron1 27-Oct-21 15:39pm    
Do you have a question?
arus_prime 27-Oct-21 15:42pm    
I would like help answering those examples
jeron1 27-Oct-21 15:46pm    
Post what you have tried, and try to ask specific questions.
arus_prime 27-Oct-21 15:48pm    
I'm sorry in a while I'll post it
Member 15329613 27-Oct-21 16:13pm    
You need to ask a specific question. No one has the time to go through and explain everything about every single line so you need to be specific.

1 solution

That code won't compile, and if it did, it wouldn't work: so fix that first.
This line does nothing:
endl;
It requires a cout
The efila function is lacking a closing "}".
The ecolumna function is missing an open "{", a closing "}", and probably the keyword for here:
(fi=f; fi < n; fi++){
and here:
(f=0; f< n; f++){
This definition needs needs a type:
m[50][50];
And so on.

Get your framework working, then start answering the questions you have been set.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 
v2
Comments
CPallini 28-Oct-21 2:07am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900