C++,while(~scanf("%d",&n))表示当输入空格时结束输入?下面是代码
#include<stdio.h>intmain(){freopen("data.in","r",stdin);freopen("data.out","w",stdout...
#include <stdio.h>
int main()
{
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
int s[15][15];
int n;
while(~scanf("%d",&n)) //这里
{
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
scanf("%d",&s[i][j]);
}
}
int max=0;
for(int i=0;i<n-1;i++)
for(int j=0;j<n-1;j++)
{
max=s[i][j]+s[i][j+1]+s[i+1][j]+s[i+1][j+1]>max?s[i][j]+s[i][j+1]+s[i+1][j]+s[i+1][j+1]:max;
}
double ans=max*1.0/4.0;
printf("%.2lf\n",ans);
}
return 0;
} 展开
int main()
{
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
int s[15][15];
int n;
while(~scanf("%d",&n)) //这里
{
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
scanf("%d",&s[i][j]);
}
}
int max=0;
for(int i=0;i<n-1;i++)
for(int j=0;j<n-1;j++)
{
max=s[i][j]+s[i][j+1]+s[i+1][j]+s[i+1][j+1]>max?s[i][j]+s[i][j+1]+s[i+1][j]+s[i+1][j+1]:max;
}
double ans=max*1.0/4.0;
printf("%.2lf\n",ans);
}
return 0;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询