當前位置:編程學習大全網 - 編程軟體 - 如何在編程中實現加法

如何在編程中實現加法

#包含“stdio.h”

int main()

{ int a[3][3],b[3][3],c[3][3],d[3][3];

//數組a+數組B結果放入數組c。

//數組a-數組B結果放入數組d。

int i,j;

for(I = 0;我& lt3;I++) //給數組a賦值。

for(j = 0;j & lt3;j++)

scanf("%d ",& ampa[I][j]);

for(I = 0;我& lt3;I++) //給數組b賦值。

for(j = 0;j & lt3;j++)

scanf("%d ",& ampb[I][j]);

Printf("輸出數組a \ n ");

for(I = 0;我& lt3;i++)

{ for(j = 0;j & lt3;j++)

printf("%4d ",a[I][j]);

printf(" \ n ");

}

Printf("輸出數組b \ n ");

for(I = 0;我& lt3;i++)

{ for(j = 0;j & lt3;j++)

printf("%4d ",b[I][j]);

printf(" \ n ");

}

Printf("數組A和數組B相加的結果:\ n ");

for(I = 0;我& lt3;i++)

{ for(j = 0;j & lt3;j++)

{ c[I][j]= a[I][j]+b[I][j];

printf("%4d ",c[I][j]);

}

printf(" \ n ");

}

Printf("數組A和數組B的相減結果:\ n ");

for(I = 0;我& lt3;i++)

{ for(j = 0;j & lt3;j++)

{ c[I][j]= a[I][j]-b[I][j];

printf("%4d ",c[I][j]);}

printf(" \ n ");

}

}

  • 上一篇:單片機編程中怎樣隱藏程序,就是怎麽把壹部分程序隱藏起來,
  • 下一篇:誰有今年奇虎360今年的後臺開發工程師筆試題,沒有的話大家說說他們考...
  • copyright 2024編程學習大全網