取字符输入并将其存储在一个阵列 [英] take char input and store it in an array
本文介绍了取字符输入并将其存储在一个阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要带输入n个,并将其保存在数组C []和P [],并随后将...
我当前写这一点,但我没有得到期望的输出
#包括LT&;&stdio.h中GT;
#包括LT&;&stdlib.h中GT;
诠释的main()
{
INT N,T,I,J,大小= 0;
个char [100000]。
焦C [100];
炭P [100];
scanf函数(%d个,&安培; N); 对于(i = 0; I< N;我++)
{
scanf函数(%C,和C [I]);
scanf函数(%C,&安培; P [i]);
} 对于(i = 0; I< N;我++)
{
的printf(%C%C,C [I],第[I]);
}
返回0;
}
解决方案
这是你的第二个评论考虑:我想这是样4 W R 2 9 F G Q T中,现在C必须存储w2fq和p应该r9gt存储,结果
你应该改变所有的的(...)
循环与为(i = 0; I< N / 2;我++)
I want to take n number of inputs and save it in the arrays c[] and p[] and later use them...
I have currently written this,but i'm not getting desired output
#include<stdio.h>
#include<stdlib.h>
int main()
{
int n,t,i,j,size=0;
char s[100000];
char c[100];
char p[100];
scanf("%d", &n);
for(i=0;i<n;i++)
{
scanf("%c", &c[i]);
scanf("%c", &p[i]);
}
for(i=0; i<n;i++)
{
printf("%c %c", c[i],p[i]);
}
return 0;
}
解决方案
Considering from your second comment: "i want it to be like 4 w r 2 9 f g q t now c should store w2fq and p should store r9gt ",
you should change all the for(...)
loop with for(i=0;i<n/2;i++)
这篇关于取字符输入并将其存储在一个阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文