實(shí)驗(yàn)7 ?一維數(shù)組、二維數(shù)組及字符串?dāng)?shù)組
任務(wù)1 ?數(shù)組的基本定義與應(yīng)用
1.4 ??3 ??3 ??2
2.6,4,3,2,
3.a=a+arr[i][j]
???j=2
???j--
i+j==2
輸出為:a=13,b=14
4.i=1
???x[i-1]
5.m<1000或m<=999
???m/10%10或m/10-x*10
???a[i]=m
???m<i或m<=i-1
???輸出結(jié)果為:153 ??370 ??371 ??407
6. a
???a
???sum/n
???x[i]<ave
任務(wù)2 ?字符數(shù)組
1.‘\0’
???str1[i]-str2[i]
2.c[k]=a[i++];
???c[k]=b[j++];
???a[i]== ‘\0’或b[j]!= ‘\0’
3.xWHOwho
4.c1!=?‘ ’&&c2==‘ ’
實(shí)驗(yàn)8 ?數(shù)組與函數(shù)
任務(wù)1 ?數(shù)組與函數(shù)的綜合應(yīng)用
蜄z ?n%2+‘0’
bin[i]=?‘\0’
2.float a[10],x;
???i<10或i<=9
???i<10或i<=9
??j<9或j<=8或j<10-i或j<=9-i
???a[j]>a[j+1]
???a[j]=a[j+1]
???i<10或i<=9
???i%5==0
3.i=strlen(a)-1;i>=j;i—
???a[i+1]=a[i]
4.m[i]=a%10
???t=t*10
???k==n*n
5.0
???||
???1
6.k-1
???N-1
???temp
7.程序代碼如下:
#include<stdio.h>
void fun(char *a)
{ ?int i=0;
???char *p=a;
???while(*p&&*p=='*')
???{a[i]=*p;
????i++;
p++;
???}
???while(*p)
???{
???if(*p!='*')
???{a[i]=*p;
?????????i++;
???}
???p++;
???}
???a[i]='\0';
}
main()
{ ?char s[81];
???printf("Enter a string:\n");
???gets(s);
???fun(s);
???printf("The string after deleted:\n");
???puts(s);
}