怎么编程可以输多行数c语言,如何多行输入并且输入后执行

谢谢ldsh304  marlow  炎天  九转星河  client苏

你们给的代码我都好好看了

int main()

{

char str2[30][31];

char temp;

int len;

int i=0;

int j=0;

while(gets(str2[i])!=NULL)           //取一行的字符串

{

len=strlen(str2[i]);

for(j=0; j

{                                           //

temp = str2[i][j];                     //

str2[i][j] = str2[i][len-1-j];         //

str2[i][len-1-j] = temp;               //

}

i++;                                        //下一行

}

for(j=i-1;j>=0;j--)                             //以ctrl+c结束

{

printf("%s\n",str2[j]);                     //输出逆反后的数组

}

return 0;

}

-----------------------------------------------分割线-------------------------1

char ch[31];

while ((gets(ch)) != null)         //取一行的字符串

{

int len = strlen(ch);          //strlen(ch)取字符串长度(到'\0'结束

for (int i = 0; i <= len/2; i++)//将数组逆反

{

char temp = ch[i];

ch[i] = ch[len-i-1];

ch[count-i-1] = temp;

}

}

-----------------------------------------------分割线-------------------------2

#include

#include

#define MAXLINE 30

int main(void)

{

char ch[MAXLINE];

int n;

while(gets(ch) != NULL)   //读取字符串

{

n = strlen(ch);

for(; n > 0; n--)

printf("%c", ch[n - 1]);    //逆反输出

}

return 0;

这是我的理解

但是

#include

void fun()

{

char ch;

if (scanf("%c",&ch)!=EOF)

fun();

if (ch!='\0')

printf("%c",ch);

}

int main()

{

fun();

printf("\n");

return 0;

}这个代码的将数组反输出在哪?

(指针还没学,我以后在回过来看)

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值