Results 1 to 7 of 7
Thread: ++
Hybrid View
-
5th January 2007 20:42 #1
++
, -
, :
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
-
5th January 2007 21:14 #2
test.dat .. :
ofstream out("test.dat", ios :: out | ios :: binary);
out.write( (char *)&mat , m*m*sizeof(double));
out.close();
-
5th January 2007 21:33 #3
, .
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();
-
5th January 2007 21:57 #4
?
.
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.
-
6th January 2007 12:20 #5
-
6th January 2007 13:24 #6
, . , [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




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