问题有点多啊,呵呵,谢谢大家的回答啊,分数最少15分,回答的好再加50分恩,谢谢啊。;-)
(1)
#include"stdio.h"
main(){
char a,b;
printf("please input two string:");
a=getchar();
b=getchar();
while(b!=0)
if(a==b)
printf("there are same numble");
else
printf("there are different numble");
getch();
}
输出是对的,就是满屏幕的there are same numble,停都停不下来恩
(2)
#include"stdio.h"
main()
{
int a[3],i,max;
printf("please input 10 numble");
for(i=0;i<=2;i++)
scanf("%d",&a[i]);
max=a[0];
for(i=1;i<=2;i++)
if(a[i]>max)
max=a[i];
printf("%d",max);
getch();}
在scanf("%d",&a[i]);的%d后面加个空格,输出就会错误,这是为什么啊?
(3)
#include"stdio.h"
main(){
char st1[30]="my name is";
char st2[10];
printf("what you name? \n");
gets (st2);
strcat(st1,st2);
puts (st1);
getch();
}
strcat什么用?是不是把ST1和ST2合并,并将合并的值给ST1,gets以及puts函数里面不能加多组数组吗?如果可以,怎么加?
我尝试在ST2中输入》10的字符,可是程序依旧正常运行,这又是为什么?
难道要大于30个程序才会出错?那么ST2中的10是不是可以写成1?
(4)
#include"string.h"
main(){
static char st1[1],st2[]="welcome to my home";
strcpy(st1,st2);
puts (st1);
getch();
}
当我ST里面为1时候,ST2的值还是可以给ST1,那么ST1设为几?或者ST2为多长时,程序输出会出现错误?
(5)#include"stdio.h"
main()
{
int a[10],i,b;
printf("please input 10 numble");
for(i=0;i<=9;i++)
scanf("%d",a[i]);
printf("%d",a[i]);
getch();}
输入数字,字母显示为-36,我觉的这个程序很对啊。
大家回答详细点可以吗?我也刚学