Partage de codes sources - CodesWall.info
C
> palindrome
Titre
palindrome
Postée le
10-04-2010
Affichée
620
Mini-lien
Description
palindrome à partir d'un fichier
Réponse
Source 360
En réponse à
Source 358
Etat
Inconnu.
Code d'insertion
Options
Tweet
Téléchargement
#include <stdio.h>
#include <string.h>
#include<conio.h>
#include<stdlib.h>
void
Creer
(
FILE
*
fp
)
{
char
f
[
30
]
;
printf
(
"fichier: /n"
)
;
scanf
(
"%s"
,f
)
;
fp
=
fopen
(
f,
"r"
)
;
if
(
fp
==
NULL
)
{
printf
(
"probleme ouverture!!!"
)
;
}
}
int
Palindrome
(
char
*
ch
)
{
int
I,J;
/* indices courants */
int
p;
/* indicateur logique: vrai si CH est un palindrome */
/* Contrôler si CH est un palindrome */
p
=
1
;
for
(
I
=
0
,J
=
strlen
(
ch
)
; p
&&
I<J ; I
++
,J
--
)
if
(
ch
[
I
]
!=
ch
[
J
]
)
p
=
0
;
return
p;
}
int
main
(
)
{
FILE
*
fp;
char
*
s;char
*
ch;
int
L,n,i,p;
Creer
(
fp
)
;
n
=
1
;
while
(
fgets
(
s,
100
,fp
)
)
{
for
(
i
=
1
;i<
=
strlen
(
s
)
;i
++
)
{
if
(
s
[
i
]
==
' '
)
{
ch
=
strncpy
(
s,ch,i
-
n
)
;
n
=
i;
}
p
=
Palindrome
(
ch
)
;
/* Affichage du résultat */
if
(
p
)
{
printf
(
"La chaîne %s est un palindrome. elle es dans la ligne %d"
,ch, L
)
;
}
else
{
printf
(
"La chaîne %s n'est pas un palindrome."
, ch
)
;
}
}
}
close
(
fp
)
;
return
(
0
)
;
}
Postez votre code-source
Informations
Catégorie *
-
Php
javascript
CSS
HTML
Xml
Perl
C
C++
Java
VB.Net
Script Batch
C#.Net
Visual Basic
VBA
Shell
mIRC
Latex
OCaml
pascal
MySQL
MatLab
Fichier .ini
SmallTalk
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
Php
(58)
javascript
(35)
CSS
(20)
HTML
(16)
Xml
(17)
Perl
(11)
C
(64)
C++
(51)
Java
(48)
VB.Net
(5)
Script Batch
(8)
C#.Net
(4)
Visual Basic
(6)
VBA
(5)
Shell
(10)
mIRC
(3)
Latex
(6)
OCaml
(4)
pascal
(9)
MySQL
(13)
MatLab
(3)
Fichier .ini
(5)
SmallTalk
(1)
Autre
(17)
\n
Forum informatique