26 Octobre
This commit is contained in:
23
DEV1.1/TP07:ChaineDeCaracteres/lecture.c
Normal file
23
DEV1.1/TP07:ChaineDeCaracteres/lecture.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main (int argc, char *argv[]){
|
||||
char mdp[27];
|
||||
char c;
|
||||
int i=0;
|
||||
strcpy(mdp,"Quoi?feur!");
|
||||
printf("Veuillez saisir un mot de passe (26 caracteres maximum): ");
|
||||
char entree[27];
|
||||
c=getchar();
|
||||
while(c!='\n'){
|
||||
entree[i]=c;
|
||||
c=getchar();
|
||||
i++;
|
||||
} if(strcmp(mdp,entree)==0){
|
||||
printf("Identification reussie !\n");
|
||||
} else{
|
||||
printf("Mot de passe incorrect, le mot de passe est Quoi?feur!\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
29
DEV1.1/TP07:ChaineDeCaracteres/statistiques.c
Normal file
29
DEV1.1/TP07:ChaineDeCaracteres/statistiques.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main (int argc, char *argv[]){
|
||||
char texte[201];
|
||||
int charU=0;
|
||||
int i;
|
||||
int j;
|
||||
int k;
|
||||
int nbrE=0;
|
||||
printf("Veuillez saisir une ligne de texte: ");
|
||||
fgets(texte,200,stdin);
|
||||
for(i=0;i<200;i++){
|
||||
if (texte[i]=='e'){
|
||||
nbrE++;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0;i<200;i++){
|
||||
k=0;
|
||||
for(j=i-1;0<j;j--){
|
||||
if (texte[j]==texte[i]){
|
||||
k=1;
|
||||
}
|
||||
}
|
||||
} printf("Il y a %d e ainsi que %d caracteres differents dans la ligne saisie.\n",nbrE,charU);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user