按列打印字符串 [英] Printing strings columnwise
问题描述
我只是想知道如何以符号方式打印两个字符串。
char string1 [] =" abcd";
char string2 [] =" ; efgh";
现在我要打印这样的东西:
ae
bf
cg
dh
i试图使用gotoxy(2,0);但它没有用。
I was just wondering how to print two strings coulmnwise.
char string1[]="abcd";
char string2[]="efgh";
now i want to print something like this:
a e
b f
c g
d h
i was trying to use gotoxy(2,0); but it is not working.
推荐答案
Umesh写道:
Umesh wrote:
>
我只是想知道如何以库存方式打印两个字符串。
char string1 [] =" abcd";
char string2 [] =" efgh";
现在我要打印这样的东西:
ae
bf
cg
dh
i试图使用gotoxy(2,0);但它不起作用。
>
I was just wondering how to print two strings coulmnwise.
char string1[]="abcd";
char string2[]="efgh";
now i want to print something like this:
a e
b f
c g
d h
i was trying to use gotoxy(2,0); but it is not working.
/ * BEGIN new.c * /
#include< stdio.h>
int main(无效)
{
char string1 [] =" abcd";
char string2 [] =" efgh";
size_t index;
for(index = 0; index!= sizeof string1; ++ index){
printf("%c%c\ n",string1 [index],string2 [index]);
}
返回0;
}
/ * END new.c * /
-
pete
/* BEGIN new.c */
#include <stdio.h>
int main(void)
{
char string1[]="abcd";
char string2[]="efgh";
size_t index;
for (index = 0; index != sizeof string1 ; ++index) {
printf("%c %c\n", string1[index], string2[index]);
}
return 0;
}
/* END new.c */
--
pete
谢谢。但是在我的程序中,我需要首先打印第一个序列
然后第二个sequnce。我希望你理解我的问题。
打印第一列中的第一个序列后,我必须打印第二列中的第二个序列。
pete写道:
Thank you. But in my program i need to print the first sequnce first
and then the second sequnce. I hope u understand my problem.
After printing the first sequence in the first column I''ve to print
the second sequence in the second column.
pete wrote:
Umesh写道:
Umesh wrote:
我只是想知道如何打印两个字符串。
char string1 [] =" abcd";
char string2 [] = efgh;
现在我要打印这样的东西:
ae
bf
cg
dh
i试图使用gotoxy(2,0);但它不起作用。
I was just wondering how to print two strings coulmnwise.
char string1[]="abcd";
char string2[]="efgh";
now i want to print something like this:
a e
b f
c g
d h
i was trying to use gotoxy(2,0); but it is not working.
/ * BEGIN new.c * /
#include< stdio.h>
int main(无效)
{
char string1 [] =" abcd";
char string2 [] =" efgh";
size_t index;
for(index = 0; index!= sizeof string1; ++ index){
printf("%c%c\ n",string1 [index],string2 [index]);
}
返回0;
}
/ * END new.c * /
-
pete
/* BEGIN new.c */
#include <stdio.h>
int main(void)
{
char string1[]="abcd";
char string2[]="efgh";
size_t index;
for (index = 0; index != sizeof string1 ; ++index) {
printf("%c %c\n", string1[index], string2[index]);
}
return 0;
}
/* END new.c */
--
pete
Umesh< fr **************** @ gmail.comwrites:
Umesh <fr****************@gmail.comwrites:
#include< stdio.h>
#include< conio.h>
#include< string.h>
int main(无效)
{
char str1 [] =" abcd",str2 [] =" efgh" ;;
int i;
for(i = 0; i< strlen(str1); i ++)
printf("%c \\\
&曲ot;,str1 [i]);
for(i = 0; i< strlen(str2); i ++)
{
gotoxy (2,i + 1);
printf("%c\ n",str2 [i]);
} //初始位置由gotoxy给出(1,1);
返回0;
}
pete写道:
#include <stdio.h>
#include <conio.h>
#include<string.h>
int main(void)
{
char str1[]="abcd",str2[]="efgh";
int i;
for(i=0;i<strlen(str1);i++)
printf("%c\n",str1[i]);
for(i=0;i<strlen(str2);i++)
{
gotoxy(2,i+1);
printf("%c\n",str2[i]);
} //initial position is given by gotoxy(1,1);
return 0;
}
pete wrote:
[snip]
两者都不是< conio.hnor gotoxy()是标准C的一部分。如果你有
的问题他们中的任何一个,你需要发布到新闻组,
他们是主题,可能是Windows或DOS组。
请不要顶级职位。阅读以下内容,了解
热门帖子以及为何不鼓励:
http://www.caliburn.nl/topposting.html
http://www.cpax.org.uk/prg/writings/topposting.php
发布后续内容时请不要更改主题标题。它b / b $ b $很难跟进讨论。原始主题是
按列打印字符串;因为你还在讨论这个问题,
改变主题标题只能引起混淆。
我记得你上次发布的一些帖子,你不知道听听建议很擅长
。我希望你有所改进。
-
Keith Thompson(The_Other_Keith) ks *** @ mib.org < http://www.ghoti.net/~kst>
圣地亚哥超级计算机中心< *< http:// users.sdsc.edu/~kst>
我们必须做点什么。这是事情。因此,我们必须这样做。
- Antony Jay和Jonathan Lynn,是部长
[snip]
Neither <conio.hnor gotoxy() is part of standard C. If you have
questions about either of them, you need to post to a newsgroup where
they''re topical, probably a Windows or DOS group.
Please don''t top-post. Read the following to understand what
top-posting is and why it''s discouraged:
http://www.caliburn.nl/topposting.html
http://www.cpax.org.uk/prg/writings/topposting.php
Please don''t change the subject header when you post a followup. It
makes it difficult to follow the discussion. The original subject was
"Printing strings columnwise"; since you''re still discussing that,
changing the subject header can only cause confusion.
I recall from your last flurry of postings here that you weren''t very
good at listening to advice. I hope you''ve improved.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
这篇关于按列打印字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!