Results 1 to 4 of 4

Thread: C++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered 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;
    }
    !!!!!!!!!

  2. #2
    Banned haste's Avatar
    Join Date: Mar:2006
    Location:
    Posts: 759
    , , :
    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:

  3. #3
    Registered User
    Join Date: Jan:2010
    Location:
    Posts: 1,646
    Quote Originally Posted by haste View Post
    , , :
    , . ,

    http://www.uctm.edu/departments/piis/CoursBG/HTMLpage24.html
    ASUS N550JK

  4. #4
    Registered User ieti's Avatar
    Join Date: Nov:2006
    Location:
    Posts: 343

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |