Results 1 to 4 of 4
Thread: C++
Hybrid View
-
22nd May 2011 06:51 #1Registered User
Join Date: May:2011
Location:
Posts: 8
C++
,
, . 2 + . Fx1 . Fx2 : , . . , . , . :
!!!!!!!!!Code:#include <iostream.h> int main(){ const int m=4; const int n=4; double A[m][n],S,S1,S2; int i,j; // A for(i=0;i < m;i++) for(j=0;j < n;j++) { cout<<"A["<< i <<"]["<< j <<"] = "; cin>>A[i][j]; } // S=S1=S2=0; // S, S1 S2 for(i=0;i < m;i++) for(j=0;j < n;j++) { S = S + A[i][j]; if (i < j) S1 = S1+A[i][j]; if (i > j) S2 = S2+A[i][j]; } // A for(i=0; i < m;i++) { for(j=0;j < n;j++) cout<<" A["<< i <<"]["<< j <<"] = "<< A[i][j]; cout<< endl; } // S, S1, S2 cout<<" A: S = " << S << endl; cout<<" : S1 = " << S1 << endl; cout<<" : S2 = " << S2 << endl; return 0; }
-
22nd May 2011 23:23 #2
, , :
1. , , . ++ , / .
2. , . , , , , , "".
3. Microsoft Visual Studio C++ . . .
4. , !
!Code:#include <stdio.h> #include <stdlib.h> #include <iostream.h> double[] computeS(int a[i][j]) { // , int i,j; int k=2; int s[k]; // s, s1 s2; , for(i=0;i < m;i++) for(j=0;j < n;j++) { s[0] = s[0] + a[i][j]; if (i < j) s[1] = s[1]+a[i][j]; if (i > j) s[2] = s[2]+a[i][j]; } return s[] } // , // s - , s1 - s2 - s[]; // .., array[] = s[] void printArray(array[]) { // , int c=0; const int m=4; const int n=4; double a[m][n]; int i,j; // for(i=0; i < m;i++) { for(j=0;j < n;j++) cout<<" a["<< i <<"]["<< j <<"] = "<< a[i][j]; cout<< endl; } // s, s1, s2 cout<<" a: s = " << array[0] << endl; cout<<" : s1 = " << array[1] << endl; cout<<" : s2 = " << array[2] << endl; } int main () { const int m=4; const int n=4; int t=2; double temp[2]; int i,j; // A for(i=0;i < m;i++) for(j=0;j < n;j++) { cout<<"A["<< i <<"]["<< j <<"] = "; cin>>a[i][j]; temp = computeS(a[i][j]); printArray(temp); }Last edited by haste; 23rd May 2011 at 00:37. Reason:
-
24th May 2011 23:21 #3Registered User
Join Date: Jan:2010
Location:
Posts: 1,646
-
26th May 2011 10:54 #4




Reply With Quote


Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in