Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Traccia 2
- #include <stdlib.h>
- #include <stdio.h>
- main()
- {
- int dim, vet[50], vet_pari[50], vet_dispari[50], i, k = 0, j = 0;
- printf("Inserire la dimensione del vettore (Massimo 50 elementi):\n");
- scanf("%d",&dim);
- for (i=0; i<dim; i++)
- {
- printf("Inserisci vet[%d]: ", i);
- scanf("%d",&vet[i]);
- }
- for (i=0; i<dim; i++)
- {
- if (vet[i]%2==0)
- {
- vet_pari[k] = vet[i];
- k++;
- }
- else
- {
- vet_dispari[j] = vet[i];
- j++;
- }
- }
- printf("vet_pari:\n");
- for (i=0; i<k; i++)
- printf("%d\n", vet_pari[i]);
- printf("vet_dispari:\n");
- for (i=0; i<j; i++)
- printf("%d\n", vet_dispari[i]);
- system("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement