View: 2713|Reply: 3
|
nak mintak tolong betulkan c code aku..
[Copy link]
|
|
nak mintak tolong sesape tolong ringkaskan code aku nie..
void Calculate()
{
for (int i=0;i<1;i++)
{
for(int j=0;j<3;j++)
{
c[i][j] = x[i][j] * w[i][j];
sum1 += c[i][j];
printf("Output[%d]: %.1f ",i+1,c[i][j]);
}
printf("\n");
printf("Sum: %.1f\n",sum1);
}
printf("\n");
for (int i=1;i<2;i++)
{
for(int j=0;j<3;j++)
{
c[i][j] = x[i][j] * w[i][j];
sum2 += c[i][j];
printf("Output[%d]: %.1f ",i+1,c[i][j]);
}
printf("\n");
printf("Sum: %.1f\n",sum2);
}
printf("\n");
for (int i=2;i<3;i++)
{
for(int j=0;j<3;j++)
{
c[i][j] = x[i][j] * w[i][j];
sum3 += c[i][j];
printf("Output[%d]: %.1f ",i+1,c[i][j]);
}
printf("\n");
printf("Sum: %.1f\n",sum3);
}
printf("\n");
for (int i=3;i<4;i++)
{
for(int j=0;j<3;j++)
{
c[i][j] = x[i][j] * w[i][j];
sum4 += c[i][j];
printf("Output[%d]: %.1f ",i+1,c[i][j]);
}
printf("\n");
printf("Sum: %.1f\n",sum4);
}
printf("\n");
}
aku nak display sum of the row.. sum1 sum first row je.. sum2 sum second row je.. and so on.. camne nak bagi ringkaskan code tu ek?? aku nie tak terer programming tu code repeat je.. hehe.. tolong ek sesape.. thanx.. |
|
|
|
|
|
|
|
- int n =your limit loop
- for ( int c =0;c<n;c++) {
- for (int i=c-1;c<1;i++) {
- {
- for(int j=0;j<3;j++)
- {
-
- c[i][j] = x[i][j] * w[i][j];
- sum1 += c[i][j];
-
- printf("Output[%d]: %.1f ",i+1,c[i][j]);
- }
- printf("\n");
- printf("Sum: %.1f\n",sum1);
- }
- }
- }
Copy the Code |
|
|
|
|
|
|
|
2# alien3d
wah.. sejak bile forum ade function nie?? da lame tak masuk forum da ubah banyak da.. anyway thanx for the code.. |
|
|
|
|
|
|
|
3# DaoMing_Si
tu ah! Nice! camne ek? |
|
|
|
|
|
|
| |
|