数组中最大值
#include<stdio.h>
int main()
{
int a[8],b,c=0;
for(b=0;b<8;b++)
{
scanf("%d",&a[b]);
if(c<a[b])
{c=a[b];}
}
printf("%d",c);
return 0;
}
============================================================================
数组逆序输出
#include<stdio.h>
int main()
{
int b,n;
printf("输入个数\n");
scanf("%d",&n);
int a[n];
for(b=0;b<n;b++)
{scanf("%d",&a[b]);}
for(b=n-1;b>=0;b--)
{printf("%d,,",a[b]);}
return 0;
}
============================================================================
数组逆序存放
#include<stdio.h>
int main()
{
int b,n,c;
printf("输入个数\n");
scanf("%d",&n);
int a[n];
for(b=0;b<n;b++)
{scanf("%d",&a[b]);}
for(b=0;b<n/2;b++)
{
c=a[b];
a[b]=a[n-b-1];
a[n-b-1]=c;
}
for(b=0;b<n;b++)
printf("%d,",a[b]);
printf("\n");
return 0;
}
============================================================================
输入二维数组
#include<stdio.h>
int main()
{
int b,c,i,k;
printf("输入行列b*c数值\n");
scanf("%d*%d",&b,&c);
int a[b][c];
for(i=0;i<b;i++)
{
for(k=0;k<c;k++)
{
scanf("%d",&a[i][k]);
}
}
for(i=0;i<b;i++)
{
for(k=0;k<c;k++)
{
printf("%d\t",a[i][k]);
}
printf("\n");
}
return 0;
}
#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=
本文来自博客园,作者:凡是过去,皆为序曲,转载请注明原文链接:https://www.cnblogs.com/longhai3/p/15887216.html
如有疑问,欢迎提问
#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=