Results 1 to 2 of 2

Thread:

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Aug:2012
    Location:
    Posts: 297

    , .
    : (nxm)
    .
    ( ) .

    Code:
    #include <iostream>
    #include <iomanip>
    #include <string>
    using namespace std;
    
    
    int main()
    {
    	int n,m,k; // nxm matrica , k prez kolko elementa da se obhojda
    	cout << "Enter n , m ,k : ";
    	cin >> n >> m >> k ; 
    	
    	cout << &m << endl << &n;
    
    	int * pointer = new int[n][m];
    
    	cout << " Enter matrix A (nxm) : " << endl;
    	for(int i = 0 ; i <= n-1 ; i++)
    		for(int j = 0; j <= m-1 ; j++)
    			cin >> pointer[i][j];
    
    	
    	
    	int * pointertmp; // ,    
    	int j = 0;
    	
    	while(j <= k )
    		{
    			j++;
    				pointertmp = pointer[0] + j;  // 
    				while(pointertmp <= pointer[n-1][m-1]) 
    				{
    					counter ++;
    					cout << *pointertmp;
    					pointertmp+=k;
    				}
    		}
    
    	cin.sync();
    	cin.get();
    	return 0;
    }
    , .
    , , , , , ., .
    , .
    Last edited by DuMBo0o; 3rd January 2014 at 16:50.

  2. #2
    Registered User hateras's Avatar
    Join Date: Jan:2011
    Location: Kronos III
    Posts: 1,028
    .
    - "" /, /, I (N*M) , -1 , I 0 -1.

    , , delete[], .

    ...
    Code:
    #include <iostream>
    #include <stdlib.h>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
    	int N = 4;
    	int M = 4;	
    	int a [N][M];
    	
    	for(int i = 0; i < N; i++) {
    		for(int j = 0; j < M; j++) {
    			a[i][j] = i*N + j;
    		}
    	}
    	
    	for(int i = 0; i < N; i++) {
    		for(int j = 0; j < M; j++) {
    			cout << "a[" << i << "," << j << "]=" << a[i][j] << " ";
    			a[i][j] = i*N + j;
    		}
    		cout << endl;
    	}
    	
    	return 0;
    }
    Visual C++?
    g++ , "" ISO C++.
    Last edited by hateras; 4th January 2014 at 19:41.
    ASRock B550M Pro 4; Ryzen R5 3600; 2x16 GiB G.SKILL Aegis 3200; 1TB Samsung QVO 960 + 3TB Seagate IronWolf; Zalman Z1

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 |