



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




#include <stdio.h> int main() { int size = 5; int tab[size]; int i,j; for( i = 0; i < size; i++){ printf("enter the value %d: ",i); scanf("%d",&tab[i]); } int extra; printf("enter the extra value"); scanf("%d",&extra); int posExtra; do{ printf("enter the position of the extra value"); scanf("%d",&posExtra);
}while((posExtra < 0) || (posExtra > size)); for(i = size-1; i > posExtra; i--){ tab[i] = tab[i-1]; } tab[posExtra] = extra; for( i = 0; i < size; i++){ printf("%d",tab[i]); }
if(tab[i]==extra){ position = i; found = true; }else{ i++; } } for(i = position; i<size-1; i++ ){ tab[i]= tab[i+1]; } tab[size-1] = 0; for( i = 0; i < size; i++){ printf("%d",tab[i]); }
#include <stdio.h> main() { int size = 6; int tab[size]; int i,j; for( i = 0; i < size; i++){ printf("enter the value %d: ",i); scanf("%d",&tab[i]); } int permutation; for( i = 0; i < size; i++){ for( j = i+1; j < size; j++){ if(tab[i]>tab[j]){ permutation = tab[j]; tab[j] = tab[i]; tab[i] = permutation; }