c程序出了死循环,只能输出到a[10][3],然后就进入死循环,再也出不来,返回不了编辑页面。程序如下

来源:百度知道 编辑:UC知道 时间:2024/05/28 00:59:08
#include <math.h>
#include <stdio.h>

void main()
{
int i=1,j=1;
double a[10][10];
for(i=1;i<11;i++)
{
for(j=1;j<11;j++)
if(i==j)
{
a[i][j]=1.5*cos(i+1.2*j);
printf("a[%d][%d]=%.12e ",i,j,a[i][j]);
}
else {
a[i][j]=sin(0.5*i+0.2*j);
printf("a[%d][%d]=%.12e ",i,j,a[i][j]);
}
printf("\n");
}
}

#include <math.h>
#include <stdio.h>

void main()
{
int i=1,j=1;
double a[10][10];
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
if(i==j)
{
a[i][j]=1.5*cos(i+1+1.2*(j+1));
printf("a[%d][%d]=%.12e ",i+1,j+1,a[i][j]);
}
else {
a[i][j]=sin(0.5*(i+1)+0.2*(j+1));
printf("a[%d][%d]=%.12e ",i+1,j+1,a[i][j]);
}
printf("\n");
}
}

在第二个for循环下面的部分用{}括起来就行了