Partage de codes sources - CodesWall.info
C
> palindrome fichier 2
Titre
palindrome fichier 2
Postée le
15-04-2010
Affichée
822
Mini-lien
Description
palindrome à partir d'un fichier v2
En réponse à
Source 360
Etat
Ne contient pas d'erreurs.
Code d'insertion
Options
Tweet
Téléchargement
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
/* Procedure creation fichier */
void
Creer
(
FILE
**
fp
)
{
char
f
[
30
]
;
printf
(
"Fichier:"
)
;
scanf
(
"%s"
,
f
)
;
*
fp
=
fopen
(
f
,
"r"
)
;
if
(
*
fp
==
NULL
)
{
printf
(
"probleme ouverture!!!"
)
;
exit
(
EXIT_FAILURE
)
;
}
}
/* fonction palindrome */
int
palindrome
(
char
*
s
)
{
int
i
,
j
,
l
;
l
=
strlen
(
s
)
;
for
(
i
=
0
,
j
=
l
-
1
;
i
<
j
;
i
++,
j
--
)
{
if
(
s
[
i
]
!=
s
[
j
]
)
return
0
;
}
return
1
;
}
int
main
(
char
*
argv
,
int
argc
)
{
FILE
*
fp
=
NULL
;
char
*
s
;
int
L
,
p
;
int
c
;
Creer
(
&
fp
)
;
L
=
1
;
while
(
(
c
=
fgetc
(
fp
)
)
!=
EOF
)
{
if
(
c
==
'
\n
'
)
{
L
=
L
+
1
;
}
fscanf
(
fp
,
"%s"
,
s
)
;
p
=
palindrome
(
s
)
;
/* Affichage du résultat */
if
(
p
==
1
)
{
printf
(
"La chaine %s est un palindrome ,elle est dans la ligne %d
\n
"
,
s
,
L
)
;
}
else
{
printf
(
""
)
;
}
}
getch
(
)
;
fclose
(
fp
)
;
return
(
0
)
;
}
Postez votre code-source
Informations
Catégorie *
-
ActionScript3
ASP
C
C#.Net
C++
COBOL
CSS
Delphi
Fichier .ini
HTML4
HTML5
Java
javascript
jQuery
Latex
MatLab
mIRC
MySQL
Objective-C
OCaml
pascal
Perl
Php
Python
QBasic
Ruby
Script Batch
Shell
SmallTalk
VB.Net
VBA
Visual Basic
XML
Autre
Titre *
(50 car. max)
Description *
(200 car. max)
Le code
Fonctionne
Ne fonctionne pas
Je ne sais pas
Source
* : Champs obligatoires
Fermer
Accueil
Poster
Actualités
Règles
Contact
Partenaires
Infos / Aide
ActionScript3
(0)
ASP
(0)
C
(65)
C#.Net
(4)
C++
(51)
COBOL
(0)
CSS
(21)
Delphi
(0)
Fichier .ini
(5)
HTML4
(16)
HTML5
(2)
Java
(48)
javascript
(35)
jQuery
(0)
Latex
(6)
MatLab
(3)
mIRC
(3)
MySQL
(13)
Objective-C
(1)
OCaml
(4)
pascal
(9)
Perl
(11)
Php
(58)
Python
(3)
QBasic
(1)
Ruby
(1)
Script Batch
(8)
Shell
(10)
SmallTalk
(1)
VB.Net
(5)
VBA
(5)
Visual Basic
(6)
XML
(17)
Autre
(18)
\n
Forum informatique