473,394 Members | 1,800 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

matrix o matrix

i have done this programming, but when the output appears I must enter any number, until 6,but i dont want to make it repeat again?how can we avoid it?

then i want to make a random number for [i][j], but i dont know how to do?
Anyone?
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <cstdlib> 
  4. #include <math.h>
  5. using namespace std;
  6.  
  7.  
  8. int  main()
  9. {
  10.     void srand ( unsigned int seed );
  11.     int a[6][6] ;
  12.     int i, j;
  13.     int x[10];
  14.     int A[10], B[10], C[10], D[10], E[10], F[10];
  15.     int clrscr();
  16.  
  17. {
  18.     for(i=1;i<7;i++)
  19.     for(j=1;j<7;j++)
  20. {
  21.     for(i=1;i<7;i++)
  22. {
  23.     x[i]=i;
  24.     A[i]=(2+pow(x[i],2));
  25.     B[i]=(1+pow(x[i],3));
  26.     C[i]=(2+pow(x[i],2)-1);
  27.     D[i]=(3*pow(x[i],3));
  28.     E[i]=(1+pow(x[i],2));
  29.     F[i]=(3+pow(x[i],2));
  30. }
  31. {
  32.     printf("\n");
  33.  
  34.     for(i=1;i<7; i++)
  35.  
  36. {   
  37.     printf("[%d][%d] A[%d]=%d\n", i,j, i, A[i]); 
  38. }
  39.     printf("\n");
  40.     for(i=1;i<7; i++)
  41.  
  42. {   
  43.     printf("[%d][%d] B[%d]=%d\n", i,j, i, B[i]); 
  44.  
  45.     printf("\n");
  46.     for(i=1;i<7; i++)
  47.  
  48. {   
  49.     printf("[%d][%d] C[%d]=%d\n", i,j, i, C[i]); 
  50.  
  51. }
  52.     printf("\n");
  53.     for(i=1;i<7; i++)
  54.  
  55. {   
  56.     printf("[%d][%d] D[%d]=%d\n", i,j, i, D[i]); 
  57.  
  58. }
  59.     printf("\n");
  60.     for(i=1;i<7; i++)
  61.  
  62. {   
  63.     printf("[%d][%d] E[%d]=%d\n", i,j, i, E[i]); 
  64.     }        
  65.     printf("\n");
  66.     for(i=1;i<7; i++)
  67.  
  68. {   
  69.     printf("[%d][%d] F[%d]=%d\n", i,j, i, F[i]); 
  70. }
  71.  
  72.     cin>>a[i] [j] ;
  73.  
  74. }
  75. }
  76. }
  77.     for(i=1;i<7;i++)
  78. {
  79.     cout<<endl;
  80.  
  81.     printf("%d\t", A[i]);
  82.     printf("%d\t", B[i]);   
  83.     printf("%d\t", C[i]);
  84.     printf("%d\t", D[i]);
  85.     printf("%d\t", E[i]);
  86.     printf("%d\t", F[i]);
  87. }
  88.     _getch();
  89.  
  90.  
  91.     printf("\n");
  92.  
  93.     printf("Random number: %d\n", rand() % 100);
  94.     srand ( 1 );
  95.  
  96.  
  97.  
  98. }
Oct 8 '07 #1
1 1145
sicarie
4,677 Expert Mod 4TB
I am extremely confused by your code. Why do you have all of the { and }'s? What do you mean when you say you 'don't want to make it repeat'? What don't you want to make repeat? The random number? Or are you assigning these yourself?

One option is to get the random number from rand() and then to a linear search of the array to see if it is in there yet. This will be very costly, time-wise, though.
Oct 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Ben Ingram | last post by:
Hi all, I am writing a template matrix class in which the template parameters are the number of rows and number of columns. There are a number of reasons why this is an appropriate tradeoff for...
5
by: Jason | last post by:
Hello. I am trying to learn how operator overloading works so I wrote a simple class to help me practice. I understand the basic opertoar overload like + - / *, but when I try to overload more...
6
by: memocan | last post by:
#include <iostream> using namespace std; int x; //global variable matrix int main() { x= new float ; //initialize the size now }
14
by: amitnanda | last post by:
Hi Guys, I have a matrix multiplication program in C that multiplies two matrices. When their size is 3*3 or 800*800, the program runs fine. But above that size, I get a "segmentation fault"....
20
by: Frank-O | last post by:
Hi , Recently I have been commited to the task of "translating" some complex statistical algorithms from Matlab to C++. The goal is to be three times as fast as matlab ( the latest) . I've...
1
by: Peterwkc | last post by:
Hello all expert, i have two program which make me desperate bu after i have noticed the forum, my future is become brightness back. By the way, my problem is like this i the first program was...
2
by: DarrenWeber | last post by:
Below is a module (matrix.py) with a class to implement some basic matrix operations on a 2D list. Some things puzzle me about the best way to do this (please don't refer to scipy, numpy and...
0
by: DarrenWeber | last post by:
# Copyright (C) 2007 Darren Lee Weber # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free...
18
by: Hypnotik | last post by:
Hello everyone. I'm writing a program which uses a class called matrix. I have written all of the different functions, constructor, etc. When I run the program I receive "Constructor", which I...
2
by: rijaalu | last post by:
I am designing a matrix class that performs addition, multicpication, substraction and division. When ever i complie the code it shows an error. include <iostream> using namespace std; class...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.