update
This commit is contained in:
28
DEV/DEV1.1/TP_ChainesDeCaracteres/#q3.c#
Normal file
28
DEV/DEV1.1/TP_ChainesDeCaracteres/#q3.c#
Normal file
@@ -0,0 +1,28 @@
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
char premiereLettre(char chaine[10]){
|
||||
int emplacement=0;
|
||||
int tailleArg;
|
||||
char caractere=chaine[emplacement];
|
||||
tailleArg=strlen(chaine);
|
||||
for (;((caractere<65)||((caractere>90)&&(caractere<97))||(caractere>122))&&(emplacement<=tailleArg); emplacement++){
|
||||
if (emplacement==tailleArg){
|
||||
return '\0';
|
||||
}
|
||||
caractere=chaine[emplacement];
|
||||
}
|
||||
return caractere;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int argument;
|
||||
char lettre;
|
||||
for (argument=1;argument<=argc;argument++){
|
||||
lettre = premiereLettre(argv[argument]);
|
||||
printf("%c",lettre);
|
||||
}
|
||||
printf("/n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
BIN
DEV/DEV1.1/TP_ChainesDeCaracteres/exe
Executable file
BIN
DEV/DEV1.1/TP_ChainesDeCaracteres/exe
Executable file
Binary file not shown.
17
DEV/DEV1.1/TP_ChainesDeCaracteres/q1.c
Normal file
17
DEV/DEV1.1/TP_ChainesDeCaracteres/q1.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
int main(void) {
|
||||
char mdp[28];
|
||||
char caractere;
|
||||
int position;
|
||||
printf("Saisissez votre mot de passe : ");
|
||||
caractere=getchar();
|
||||
for (position=0;((caractere=!'\xa')&&(position<=26));position++){
|
||||
mdp[position]=caractere;
|
||||
caractere=getchar();
|
||||
}
|
||||
mdp[position]='\0';
|
||||
printf("salut");
|
||||
printf("%s\n",mdp);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
0
DEV/DEV1.1/TP_ChainesDeCaracteres/q1.c~
Normal file
0
DEV/DEV1.1/TP_ChainesDeCaracteres/q1.c~
Normal file
28
DEV/DEV1.1/TP_ChainesDeCaracteres/q3.c
Normal file
28
DEV/DEV1.1/TP_ChainesDeCaracteres/q3.c
Normal file
@@ -0,0 +1,28 @@
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
char premiereLettre(char chaine[10]){
|
||||
int emplacement=0;
|
||||
int tailleArg;
|
||||
char caractere=chaine[emplacement];
|
||||
tailleArg=strlen(chaine);
|
||||
for (;((caractere<65)||((caractere>90)&&(caractere<97))||(caractere>122))&&(emplacement<=tailleArg); emplacement++){
|
||||
if (emplacement==tailleArg){
|
||||
return '\0';
|
||||
}
|
||||
caractere=chaine[emplacement];
|
||||
}
|
||||
return caractere;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int argument;
|
||||
char lettre;
|
||||
for (argument=1;argument<=argc;argument++){
|
||||
lettre = premiereLettre("hhvghfg");
|
||||
printf("%c",lettre);
|
||||
}
|
||||
printf("/n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
28
DEV/DEV1.1/TP_ChainesDeCaracteres/q3.c~
Normal file
28
DEV/DEV1.1/TP_ChainesDeCaracteres/q3.c~
Normal file
@@ -0,0 +1,28 @@
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
char premiereLettre(char chaine[10]){
|
||||
int emplacement=0;
|
||||
int tailleArg;
|
||||
char caractere=chaine[emplacement];
|
||||
tailleArg=strlen(chaine);
|
||||
for (;((caractere<65)||((caractere>90)&&(caractere<97))||(caractere>122))&&(emplacement<=tailleArg); emplacement++){
|
||||
if (emplacement==tailleArg){
|
||||
return '\0';
|
||||
}
|
||||
caractere=chaine[emplacement];
|
||||
}
|
||||
return caractere;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int argument;
|
||||
char lettre;
|
||||
for (argument=1;argument<=argc;argument++){
|
||||
lettre = premiereLettre(argv[argument]);
|
||||
printf("%c",lettre);
|
||||
}
|
||||
printf("/n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
30
DEV/DEV1.1/TP_ChainesDeCaracteres/q4.c
Normal file
30
DEV/DEV1.1/TP_ChainesDeCaracteres/q4.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
#include<math.h>
|
||||
|
||||
int strint(char chaine[10]){
|
||||
int digit=strlen(chaine)-1;
|
||||
int longueur=digit;
|
||||
int resultat=0;
|
||||
int chiffre;
|
||||
for (;digit>=0;digit--){
|
||||
chiffre = chaine[digit]-48;
|
||||
if ((chiffre<0)||(chiffre>9)){
|
||||
return 0;
|
||||
}
|
||||
resultat += (chiffre)*pow(10,(-digit+longueur));
|
||||
}
|
||||
return(resultat);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
if (argc > 2) {
|
||||
int resultat;
|
||||
resultat = strint(argv[1])*strint(argv[2]);
|
||||
printf("%d\n",resultat);
|
||||
} else {
|
||||
puts("Saisissez au moins 2 premiers arguments entiers !");
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
34
DEV/DEV1.1/TP_ChainesDeCaracteres/q4.c~
Normal file
34
DEV/DEV1.1/TP_ChainesDeCaracteres/q4.c~
Normal file
@@ -0,0 +1,34 @@
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
#include<math.h>
|
||||
|
||||
int puissance(int a, int b){
|
||||
int c;
|
||||
int resultat=0;
|
||||
for (c=0;c<b;c++){
|
||||
resultat = resultat*resultat;
|
||||
}
|
||||
}
|
||||
|
||||
int strint(char chaine[10]){
|
||||
int digit=strlen(chaine)-1;
|
||||
int longueur=digit;
|
||||
int resultat=0;
|
||||
for (;digit>=0;digit--){
|
||||
printf(("%d = %d * 10**%d\n",(int)chaine[digit]), (int)chaine[digit])*puissance(10,(-digit+longueur)),(-digit+longueur));
|
||||
resultat += ((int)chaine[digit])*puissance(10,(-digit+longueur));
|
||||
}
|
||||
return(resultat);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
if (argc > 1) {
|
||||
int resultat;
|
||||
resultat = strint(argv[1]);
|
||||
printf("%d\n",resultat);
|
||||
} else {
|
||||
puts("aucun argument !");
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
7
DEV/DEV1.1/TP_ChainesDeCaracteres/test.c
Normal file
7
DEV/DEV1.1/TP_ChainesDeCaracteres/test.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
int main(void) {
|
||||
char a=getchar();
|
||||
printf("%x\n",getchar());
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
15
DEV/DEV1.1/TP_ChainesDeCaracteres/test.c~
Normal file
15
DEV/DEV1.1/TP_ChainesDeCaracteres/test.c~
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
int main(void) {
|
||||
char mdp[28];
|
||||
char caractere;
|
||||
int position;
|
||||
printf("Saisissez votre mot de passe : ");
|
||||
caractere=getchar();
|
||||
for (position=0;)(position<=26);position++){
|
||||
mdp[position]=caractere;
|
||||
caractere=getchar();
|
||||
}
|
||||
printf("%s\n",mdp);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
0
DEV/DEV1.1/TP_ChainesDeCaracteres/test.txt~
Normal file
0
DEV/DEV1.1/TP_ChainesDeCaracteres/test.txt~
Normal file
Reference in New Issue
Block a user