1.编写程序,定义整型指针变量p,初始化整型一维数组a的首地址(数组a的长度为10),利用指针变量p实现从键盘输入10个整型数据到一维数组a中,并输出该数组中最大值和最大值元素的下标。
1.Write a C program that declares an integer type pointer variable initialized the initial address of array a (the length is 10). You’re your program use the pointer variable p to store the numbers to the one-dimensional array a form the keyboard inputting and output the maximum and it’s subscript of the array a.
#include<stdio.h>
int main()
{
int i,max,sub=0,a[10];
int *p=a;
for(i=0;i<10;i++)
scanf("%d",p+i);
max=a[0];
for(i=0;i<10;i++,p++)
{
if(*p>max)
{
max=*p;
sub=i+1;
}
}
printf("MAX=%d,subscript=%d",max,sub);
return 0;
}
2.编写程序,实现删除字符串s中的所有空格,其中实现字符串空格删除功能要求定义一个形式参数为字符指针的函数。
2.Write a C program that defines a function with a character pointer as formal parameter to delete the blank space in the string s.
#