1.
#include
#include
void main()
{
char a[100],b[100];
printf("请输入字符串a:");
gets(a);
printf("请输入字符串b:");
gets(b);
if(strcmp(a,b) == 0)
printf("a == b\n");
else
printf("a!=b\n");
}
2.
#include
#include
void main()
{
char a[100],b[100];
printf("请输入字符串a:");
gets(a);
printf("请输入字符串b:");
gets(b);
strcat(a,b);
printf("a+b = %s\n",a);
}
3.
#include
int main(void)
{
int a[5] = {0,3,5,6,8};//第一个有序数组
int b[7] ={2,4,7,9,10,16,20};//第二个有序数组
int c[20];//待放入的数组
int i, j, k;
i = j = k = 0;
while (i < 5 && j < 7)
{
if (a[i] < b[j])
c[k++] = a[i++];
else
c[k++] = b[j++];
}
while (i < 5)
c[k++] = a[i++];
while (j < 7)
c[k++] = b[j++];
printf("新的有序数组为:");
for(i = 0; i < 12; i++)
printf("%d ",c[i]);
printf("\n");
}