Results 1 to 7 of 7

Thread: ++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User Neverine's Avatar
    Join Date: Sep:2004
    Location: /
    Posts: 721

    ++

    , -
    , :
    MxM , , . , [a,b). , . .

    - " "( , - , ). , ( ) cin.getline ."" ... ?

    btw :
    Code:
    #include <iostream.h>
    #include <fstream.h>
    int main()
    {
    	const int m=2;
    	double mat[m][m];
    
    	ifstream a_file ("c:/yeah.txt");
    		for (int i=0 ; i<m ; i++)
    		{
    			for (int j=0 ; j<m ; j++)
    			{
    				a_file >> mat[i][j];
    			}
    		}
    	
    	double a,b;
    	double pro=1;
    	
    	
    	cout <<"a=";
    	cin >>a;
    	cout <<"b=";
    	cin >>b;
    	for (i=0 ;i<m ;i++)
    	{
    		for (int j=0 ;j<m ; j++)
    		{
    			if ((mat[i][j]>=a)&&(mat[i][j]<b))
    				pro=pro*mat[i][j];
    		}
    	}
    	cout <<pro<<endl;
    	int red=-1;
    	double min=a;
    	for (i=0 ;i<m ;i++)
    	{
    		for (int j=0 ;j<m ;j++)
    		{	
    			if ((mat[i][j]>=a)&&(mat[i][j]<b))
    			{
    				if (min>(mat[i][j]))
    				{	
    					min=mat[i][j];
    					red=i;
    				}
    			}
    		}
    	}
    	
    	if (red == -1) cout << "nqma elementi w intervala [a,b)" ;
    		else 
    		{
    			cout << "minimalen element =" <<min;
    			cout << "red na minimalniq element =" << red;
    		}
    	
    	double mat2[m-1][m];
    	for (i=0 ;i<red-1 ; i++)
    	{
    		for (int j=0 ;j<m ; j++)
    		{
    			mat2[i][j]=mat[i][j];
    		}
    	}
    	for (i=red ;i<m-1 ;i++)
    	{
    		for (int j=0 ;j<m ;j++)
    		{
    			mat2[i][j]=mat[i+1][j];
    		}
    	}
    	a_file.close();
    	ofstream b_file ("c:/yeah.txt" , ios::app);
    	for (i=0 ; i<m-1 ; i++)
    	{
    		for (int j=0 ; j<m ; j++)
    		{
    			b_file << mat[i][j];
    			cout << mat[i][j];
    		}
    	};
    
    	return 0;
    }
    .
    .
    EDIT : - yeah.txt , (.. ...) .
    yeah.txt :
    1 5
    3 10
    Last edited by Neverine; 5th January 2007 at 21:23.
    P5Q Deluxe | E8500 | EK-Supreme + MCP655 + MCR220 + Feser Tube | 2*2GB A-Data 800 | GB HD3850 256MB | WD6401AALS | Lite-on 20A1S | PC P&C Silencer 610W | Antec P182 | Belinea 102035
    F2 F3

  2. #2
    Registered User vegasis's Avatar
    Join Date: Jun:2005
    Location:
    Posts: 1,156
    test.dat .. :

    ofstream out("test.dat", ios :: out | ios :: binary);
    out.write( (char *)&mat , m*m*sizeof(double));
    out.close();

  3. #3
    Registered User Neverine's Avatar
    Join Date: Sep:2004
    Location: /
    Posts: 721
    , .
    btw edit- ...
    Code:
    ofstream b_file ("c:/yeah.txt" , ios::app);
    	for (i=0 ; i<m-1 ; i++)
    	{
    		for (int j=0 ; j<m ; j++)
    		{
    			b_file << mat[i][j];
    			cout << mat[i][j];
    		}
    	};
    Code:
    ofstream out("c:/yeah.txt", ios :: out | ios :: binary);
    	out.write( (char *)&mat , m*m*sizeof(double));
    	out.close();
    , ,
    P5Q Deluxe | E8500 | EK-Supreme + MCP655 + MCR220 + Feser Tube | 2*2GB A-Data 800 | GB HD3850 256MB | WD6401AALS | Lite-on 20A1S | PC P&C Silencer 610W | Antec P182 | Belinea 102035
    F2 F3

  4. #4
    Registered User vegasis's Avatar
    Join Date: Jun:2005
    Location:
    Posts: 1,156
    ?
    .
    DOS .

    ofstream out("test.dat", ios :: out | ios :: binary);
    // c:/yeah.txt "c:\\yeah.txt" , escape
    int j=0;

    for (i=0 ; i<m ; i++)
    { for (j=0 ; j<m ; j++) out.write( (char *)&mat[i][j] , sizeof(double)); };
    Last edited by vegasis; 5th January 2007 at 22:10.

  5. #5
    Registered User Neverine's Avatar
    Join Date: Sep:2004
    Location: /
    Posts: 721
    , ... ...
    , , cout-a :
    Code:
    int red=-1;
    	double min=a;
    	for (i=0 ;i<m ;i++)
    	{
    		for (int j=0 ;j<m ;j++)
    		{	
    			if ((mat[i][j]>=a)&&(mat[i][j]<b))
    			{
    				if (min>(mat[i][j]))
    				{	
    					min=mat[i][j];
    					red=i;
    				}
    			}
    		}
    	}
    P5Q Deluxe | E8500 | EK-Supreme + MCP655 + MCR220 + Feser Tube | 2*2GB A-Data 800 | GB HD3850 256MB | WD6401AALS | Lite-on 20A1S | PC P&C Silencer 610W | Antec P182 | Belinea 102035
    F2 F3

  6. #6
    Deleted User 4eRNoBiL's Avatar
    Join Date: Oct:2005
    Location:
    Posts: 739
    , . , [a,b). , "a" min, , - - . , - .
    , "double min=a;" "double min=b;". - - .

    , - , i - - ++,
    Code:
    #include <iostream.h>
    #include <fstream.h>
    Code:
    #include <iostream>
    #include <fstream>
    
    using namespace std;
    Fujistu Lifebook E756 | Core i7-6500U / 400MHz-3.1GHz | 8 GB DDR4-2133 | Samsung PM871 / 256 GB SSD | 15" 1920x1080 | Manjaro Linux + kernel 4.19

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 |