实验代码一
include<stdio.h>
include<stdlib.h>
int main()
{
FILE*fp;
int sum,t,i,j,n,m;
int a[n];
if((fp=fopen("C:\yefei\.txt","w"))==NULL)
{
printf("File open error!
");
exit(0);
}
scanf("%d",&n);
fprintf(fp,"%d
",n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
fprintf(fp,"%d,",a[i]);
}
t=a[0]; //假设
for(i=0;i<n;i++)
{
sum=0;
for(j=i;j<n;j++)
{
m=a[j];
sum+=a[j];
if(m<sum)
{
m=sum;
}
}
if(t<m)
{
t=m;
}
}
fprintf(fp,"
%d",t);
if(fclose(fp))
{
printf("Can not close the file!
");
exit(0);
}
return 0;
}
截图一
实验代码二
include<stdio.h>
int main()
{
int T;
scanf("%d
",&T);
int i,j,t,n;
int a[10][10],Tab[100];
for(t=1;t<=T;t++){
n=1;
scanf("%d
",&Tab[t]);
for(i=0;i<Tab[t];i++){
for(j=0;j<Tab[t];j++){
scanf("%d",&a[i][j]);
if(i>j){
if(a[i][j]!=0) {
n=0;
}
}
}
}
if(n) printf("YES
");
else printf("NO
");
}
return 0;
}
截图二