#include <stdio.h>
int main(int argc, const char *argv[])
{
int arr[5];
int i,j,num;
int n=0;
printf("请输入整数填充数组:\n");
for(i=0;i<5;i++){
scanf("%d",&arr[i]);
}
printf("再输入一个数num:\n");
scanf("%d",&num);
for(i=0;i<5;i++){
if(num==arr[i]){
printf("num在数组arr中\n");
}else{
n+=1;
}
if(n==5){
printf("num不在数组中\n");
}
}
return 0;
}
#include <stdio.h>
int main(int argc, const char *argv[])
{
int arr[5];
int i,j,num,max,min,sum;
sum=0;
printf("请输入整数填充数组:\n");
for(i=0;i<5;i++){
scanf("%d",&arr[i]);
sum+=arr[i];
}
printf("数组中所有数的和是:%d\n",sum);
printf("数组中所有数的平均值:%d\n",sum/5);
for(i=0;i<5;i++){
if(arr[i]>=arr[i+1]){
arr[i+1]=arr[i];
}
}
printf("数组中所有数的最大值是:%d\n",arr[4]);
for(i=0;i<5;i++){
if(arr[i]<=arr[i+1]){
arr[i+1]=arr[i];
}
}
printf("数组中所有数的最小值是:%d\n",arr[4]);
return 0;
}
int main(int argc, const char *argv[])
{
int a[]={1,2,3,4,5,6,7,8};
int i=0,b=0;
b=sizeof(a)/sizeof(int);
printf("数组的长度是:%dbyte\n",b);
for(i=0;i<8;i++){
if(i%2==1){
a[i]=a[i]*3;
}else{
a[i]=a[i]+2;
}
}
printf("数组中的数依次是:");
for(i=0;i<8;i++){
printf("%d\t",a[i]);
}
return 0;
}