Solution_Série4_ASD En
Solution_Série4_ASD En
Exercice 1 :
Exercice 2 :
3
Exercice 6 :
4
#include <stdio.h> //Calcule J_max et J_min
int main() { max=min=S[0];
int M[10][10],S[10],i,j,n,m,max,J_max,min,J_min,temp; J_max=J_min=0;
printf("enter n and m :"); for (i=1;i<m;i++)
scanf("%d%d",&n,&m); if(max<S[i]){
for (i=0;i<n;i++) max=S[i];
for (j=0;j<m;j++){ J_max=i;
printf("M[%d][%d]=",i,j); }else
scanf("%d",&M[i][j]); if(min>S[i]){
} min=S[i];
for (j=0;j<m;j++){ J_min=i;
S[j]=0; }
for (i=0;i<n;i++) printf("\nVal Max : S[%d]=%d\n",J_max,max);
S[j]+=M[i][j]; printf("\nVal Min : S[%d]=%d\n",J_min,min);
} // permutation
for (i=0;i<n;i++){
printf("\nM before permutation :\n"); temp=M[i][J_max];
for (i=0;i<n;i++){ M[i][J_max]=M[i][J_min];
for (j=0;j<m;j++) M[i][J_min]=temp;
printf("%.2d\t",M[i][j]); }
printf("\n");
} printf("\nM after permutation :\n");
printf("\nSum_Columns :\n"); for (i=0;i<n;i++){
for (j=0;j<m;j++)
for (i=0;i<m;i++){ printf("%.2d\t",M[i][j]);
printf("%.2d\t",S[i]); printf("\n");
}
} return 0;}
}
5
Exercice 7:
6
Exercice 8:
#include <stdio.h>
Algorithm S4_EXO8
#include <string.h>
Variables int main() {
ch1, ch2: Array[0..49] of character char ch1[50],ch2[50];
co, i, j, test: integer int co=0,i,j,test;
Begin printf("entrer Ch1\n");
write("Enter Ch1") scanf("%s",ch1);
read(ch1) getchar();
write("Enter Ch2") printf("entrer Ch2\n");
read(ch2) scanf("%s",ch2);
co ← 0 getchar();
for i=0 to length(ch1)-1 do for(i=0;i<strlen(ch1);i++){
test ← 1 test=1;
j←0
j=0;
while j < length(ch2) and test = 1 do
while(j<strlen(ch2) && test==1){
if (ch1[i+j] <> ch2[j]) then
test ← 0 if(ch1[i+j]!=ch2[j])
end if test=0;
j←j+1 j++;
end while }
if (test = 1) then if(test==1)
co ← co + 1 co++;
end if }
end for printf("Ch2 exists %d times in Ch1",co);
write("Ch2 exists", co, " times in Ch1") return 0;
End }