Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 6) Dado un número n, rellene aleatoriamente
- el arreglo (Bn), posteriormente, buscarlos elementos
- de Bn que son primos y mostrarlos en pantalla.*/
- #include<stdio.h>
- #include<stdlib.h>
- #include<time.h>
- int V[50],i,x,z=1,cont,y;
- int main (){
- printf("Tamano de tu arreglo\n");
- scanf("%i",&x);
- srand(time(NULL));
- for(i=0; i<x; i++){
- V[i]=rand();
- printf("%d\n",V[i]);
- }
- for(i=0; i<x; i++){
- while(z<=V[i]){
- z++;
- if(V[i]%z==0){
- cont++;
- }
- if(cont<2){
- y=i;
- printf("EL es primo %d\n",V[y]);
- break;
- }
- }
- }
- printf("\n\n");
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment