Article View: fr.comp.lang.c
Article #15229Re: rot13 [Was : Re: conjugaison et autres ...]
From: Emmanuel Delahaye
Date: Sun, 02 Oct 2005 19:35
Date: Sun, 02 Oct 2005 19:35
78 lines
3447 bytes
3447 bytes
candide wrote on 02/10/05 :
> #include <stdio.h>
> #include <ctype.h>
>
> int main(void)
> {
> char minus[]="abcdefghijklmnopqrstuvwxyzabcdefghijklm";
> char majus[]="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM";
> char phrase[200]="Preface : The computing world has undergone a
> revolution since the publication of \"The C Programming Language\" in
> 1978.";
> int i=0;
> char *p;
>
> while (phrase[i]!='\0') {
> if (islower(phrase[i]))
> {p=strchr(minus,phrase[i]); printf("%c",*(p+13));}
> else if (isupper(phrase[i]))
> {p=strchr(majus,phrase[i]); printf("%c",*(p+13));}
> else printf("%c",phrase[i]);
> i++;
> }
>
> return 0;
> }
Excellent! Quelques corrections et am�liorations :
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main (void)
{
char minus[] = "abcdefghijklmnopqrstuvwxyzabcdefghijklm";
char majus[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM";
char phrase[200] = "Preface : The computing world has undergone a"
" revolution since the publication of \"The C Programming
Language\""
" in 1978.\n";
/*
Cersnpr : Gur pbzchgvat jbeyq unf haqretbar n eribyhgvba fvapr gur
choyvpngvba b
s "Gur P Cebtenzzvat Ynathntr" va 1978.
*/
char *pc = phrase;
int c;
while ((c = *pc) != 0)
{
if (islower (c))
{
char *p = strchr (minus, c);
putchar (p[13]);
}
else if (isupper (c))
{
char *p = strchr (majus, c);
putchar (p[13]);
}
else
{
putchar (c);
}
pc++;
}
return 0;
}
--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html
"C is a sharp tool"
Technical Details
Message-ID:
<mn.150f7d5a4aa81b4e.15512@YOURBRAnoos.fr>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsread.com!news-xfer.newsread.com!newspeer.monmouth.com!newsfeed.icl.net!newsfeed.fjserv.net!nntp.theplanet.net!inewsm1.nntp.theplanet.net!pe2.news.blueyonder.co.uk!blueyonder!proxad.net!infeed-1.proxad.net!news18-e.free.fr!not-for-mailReferences:
<1126342327.583568.21420@g43g2000cwa.googlegroups.com> <4329e5d4$0$7846$8fcfb975@news.wanadoo.fr> <dge4b6$fqa$1@reader1.imaginet.fr> <432ab809$0$1734$8fcfb975@news.wanadoo.fr> <mn.84b07d59016a857b.31483@laposte.net> <433f16ac$0$27406$8fcfb975@news.wanadoo.fr> <mn.10907d5a55119e84.15512@YOURBRAnoos.fr> <433f9cb1$0$7821$8fcfb975@news.wanadoo.fr> <mn.128c7d5aa5238de0.15512@YOURBRAnoos.fr> <43402c57$0$1702$8fcfb975@news.wanadoo.fr>Show Full Headers
Complete Article Headers
X-Google-Thread: f9822,b21b26167a936e28 X-Google-Attributes: gidf9822,public X-Google-Language: ENGLISH,ASCII Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsread.com!news-xfer.newsread.com!newspeer.monmouth.com!newsfeed.icl.net!newsfeed.fjserv.net!nntp.theplanet.net!inewsm1.nntp.theplanet.net!pe2.news.blueyonder.co.uk!blueyonder!proxad.net!infeed-1.proxad.net!news18-e.free.fr!not-for-mail Subject: Re: rot13 [Was : Re: conjugaison et autres ...] From: "Emmanuel Delahaye" <emdel@YOURBRAnoos.fr> References: <1126342327.583568.21420@g43g2000cwa.googlegroups.com> <4329e5d4$0$7846$8fcfb975@news.wanadoo.fr> <dge4b6$fqa$1@reader1.imaginet.fr> <432ab809$0$1734$8fcfb975@news.wanadoo.fr> <mn.84b07d59016a857b.31483@laposte.net> <433f16ac$0$27406$8fcfb975@news.wanadoo.fr> <mn.10907d5a55119e84.15512@YOURBRAnoos.fr> <433f9cb1$0$7821$8fcfb975@news.wanadoo.fr> <mn.128c7d5aa5238de0.15512@YOURBRAnoos.fr> <43402c57$0$1702$8fcfb975@news.wanadoo.fr> Newsgroups: fr.comp.lang.c Message-ID: <mn.150f7d5a4aa81b4e.15512@YOURBRAnoos.fr> X-Newsreader: MesNews/1.04.00.00-fr Date: Sun, 02 Oct 2005 21:35:07 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15"; format=flowed Content-Transfer-Encoding: 8bit Lines: 80 Organization: Guest of ProXad - France NNTP-Posting-Date: 02 Oct 2005 21:35:13 MEST NNTP-Posting-Host: 81.65.109.78 X-Trace: 1128281713 news18-e.free.fr 18070 81.65.109.78:20631 X-Complaints-To: abuse@proxad.net