关于杨辉三角打出十行的,代码都差不多,运行很奇怪


#include <iostream>
#include <stdlib.h>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{      int i,j;
       int a[10][10];
   for (i=0;i<10;i++);
   {   a[i][i]=1;
       a[i][0]=1;
   }
   for(i=2;i<10;i++)
   {   for(j=1;j<i;j++)
        a[i][j]=a[i-1][j-1]+a[i-1][j];    
   }
    for(i=0;i<10;i++)
   {   for(j=0;j<=i;j++)
       cout<<a[i][j]<<setw(12);
       cout<<endl;
   }
     system("pause");
     return 0;
}

img

题主代码的问题:
img
这句 for() 最后多了 ’;' 。

img
这句应改为:

cout << setw(12) << a[i][j];


#include"stdio.h" 
void main()
{
  int a[10][10],i,j;
  for(i=0;i<=9;i++){
    a[i][0]=1;
    a[i][i]=1;
  }
  for(i=1;i=9;i++)
    for(j=1;j<i;j++)
      a[i][j]=a[i-1][j-1]+a[i-1][j];
    for(i=0;i<=9;i++){
      for(j=0;j<=i;j++)
        {printf("%5d\t",a[i][j]);}
      printf("\n");
      }
  return 0;
}