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? -
#include <iostream>
-
#include <conio.h>
-
#include <cstdlib>
-
#include <math.h>
-
using namespace std;
-
-
-
int main()
-
{
-
void srand ( unsigned int seed );
-
int a[6][6] ;
-
int i, j;
-
int x[10];
-
int A[10], B[10], C[10], D[10], E[10], F[10];
-
int clrscr();
-
-
{
-
for(i=1;i<7;i++)
-
for(j=1;j<7;j++)
-
{
-
for(i=1;i<7;i++)
-
{
-
x[i]=i;
-
A[i]=(2+pow(x[i],2));
-
B[i]=(1+pow(x[i],3));
-
C[i]=(2+pow(x[i],2)-1);
-
D[i]=(3*pow(x[i],3));
-
E[i]=(1+pow(x[i],2));
-
F[i]=(3+pow(x[i],2));
-
}
-
{
-
printf("\n");
-
-
for(i=1;i<7; i++)
-
-
{
-
printf("[%d][%d] A[%d]=%d\n", i,j, i, A[i]);
-
}
-
printf("\n");
-
for(i=1;i<7; i++)
-
-
{
-
printf("[%d][%d] B[%d]=%d\n", i,j, i, B[i]);
-
-
}
-
printf("\n");
-
for(i=1;i<7; i++)
-
-
{
-
printf("[%d][%d] C[%d]=%d\n", i,j, i, C[i]);
-
-
}
-
printf("\n");
-
for(i=1;i<7; i++)
-
-
{
-
printf("[%d][%d] D[%d]=%d\n", i,j, i, D[i]);
-
-
}
-
printf("\n");
-
for(i=1;i<7; i++)
-
-
{
-
printf("[%d][%d] E[%d]=%d\n", i,j, i, E[i]);
-
}
-
printf("\n");
-
for(i=1;i<7; i++)
-
-
{
-
printf("[%d][%d] F[%d]=%d\n", i,j, i, F[i]);
-
}
-
-
cin>>a[i] [j] ;
-
-
}
-
}
-
}
-
for(i=1;i<7;i++)
-
{
-
cout<<endl;
-
-
printf("%d\t", A[i]);
-
printf("%d\t", B[i]);
-
printf("%d\t", C[i]);
-
printf("%d\t", D[i]);
-
printf("%d\t", E[i]);
-
printf("%d\t", F[i]);
-
}
-
_getch();
-
-
-
printf("\n");
-
-
printf("Random number: %d\n", rand() % 100);
-
srand ( 1 );
-
-
-
-
}
1 1145
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
by: memocan |
last post by:
#include <iostream>
using namespace std;
int x; //global variable matrix
int main()
{
x= new float ; //initialize the size now
}
|
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"....
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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...
|
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...
| |