13 Replies - 928 Views - Last Post: 12 November 2019 - 05:26 PM Rate Topic: -----

#1 JR360   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 27-September 19

Data Analysis Question

Posted 27 September 2019 - 06:38 PM

#include <iostream>
#include <time.h>

using namespace std;

void choose(int a,int b,int c,int d[]);
void screen(int a[],int B)/>/>;

int main(){
    int plays;
    int numbers;
    int price=plays*2;
    int playerNumbers[]={};
    
    choose(numbers,plays,price,playerNumbers);
    screen(playerNumbers,plays);
}

void choose(int a,int b,int c,int d[]){
    cout << "How many numbers? : ";
    cin >> a;
    cout << "How many plays? : ";
    cin >> b;
    cout << "That will cost " << c << endl;
    
    for(int i=1;i<=5;i++){
        cout << "Number" << i << ":";
        cin >> d[i];
    }
}

void screen(int a[],int B)/>/>{
    for(int i=1;i<=5;i++){
        cout << i;
        for(int j=0;j<5;j++){
            cout << "[" << a[j+1] << "]";
        }
        cout << endl;
    }
}
:code:
My Question is how can i change the orders of the numbers in every line and how can i change the order from min to max. Simple lotto app for fun. in c++ code

This post has been edited by modi123_1: 27 September 2019 - 07:53 PM
Reason for edit:: In the future please use the [code] tag button in the editor


Is This A Good Question/Topic? 0
  • +

Replies To: Data Analysis Question

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15357
  • View blog
  • Posts: 61,575
  • Joined: 12-June 08

Re: Data Analysis Question

Posted 27 September 2019 - 07:13 PM

Store them in a collection or array and sort.
Was This Post Helpful? 0
  • +
  • -

#3 JR360   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 27-September 19

Re: Data Analysis Question

Posted 27 September 2019 - 07:43 PM

View Postmodi123_1, on 27 September 2019 - 07:13 PM, said:

Store them in a collection or array and sort.

What do you mean array and sort? So far I learn little about coding and is not easy, can you help me with this I just started a month ago.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15357
  • View blog
  • Posts: 61,575
  • Joined: 12-June 08

Re: Data Analysis Question

Posted 27 September 2019 - 07:56 PM

I would suggest reading up on arrays then. The more direct route.

http://www.cplusplus...icles/NhA0RXSz/
https://www.dreaminc...al-1-using-sort
Was This Post Helpful? 0
  • +
  • -

#5 jimblumberg   User is offline

  • member icon

Reputation: 5771
  • View blog
  • Posts: 17,670
  • Joined: 25-December 09

Re: Data Analysis Question

Posted 28 September 2019 - 05:18 AM

By the way the following is illegal in C++: int playerNumbers[]={};.

First an array in C++ must have a size, you can not create an array without a size.

Second the size must be a compile time constant. You can not create statically allocated arrays with "runtime determined" sizes in C++. Example:

int playersNumbers[100]; // Okay, size is a constant.

int arraySize = 100;
int playersNumbers[arraySize]; // Bad the size is not a compile time const.

const int arraySize 100;
int playersNumbers[arraySize]; Okay size is a compile time constant.




Jim
Was This Post Helpful? 0
  • +
  • -

#6 JR360   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 27-September 19

Re: Data Analysis Question

Posted 17 October 2019 - 05:48 PM

Jim Blumberg, hi there you answer my question with this, but I still don't understand to apply the array size. it's possible for you to take a look at this code, please.
#include <iostream>
#include <time.h>

using namespace std;

void choose(int a,int b,int c,int d[]);
void screen(int a[],int B)/>/>/>/>;

int main(){
    int plays;
    int numbers;
    int price=plays*2;
  
    
    choose(numbers,plays,price,playerNumbers);
    screen(playerNumbers,plays);
}

void choose(int a,int b,int c,int d[]){
    cout << "How many numbers? : ";
    cin >> a;
    cout << "How many plays? : ";
    cin >> b;
    cout << "That will cost " << c << endl;
    
    for(int i=1;i<=5;i++){
        cout << "Number" << i << ":";
        cin >> d[i];
    }
}

void screen(int a[],int B)/>/>/>/>{
    for(int i=1;i<=5;i++){
        cout << i;
        for(int j=0;j<5;j++){
            cout << "[" << a[j+1] << "]";
        }
        cout << endl;
    }
}


This post has been edited by Skydiver: 17 October 2019 - 06:18 PM
Reason for edit:: Removed unnecessary quote. Put code in code tags. Learn to do this yourself.

Was This Post Helpful? 0
  • +
  • -

#7 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7135
  • View blog
  • Posts: 24,240
  • Joined: 05-May 12

Re: Data Analysis Question

Posted 17 October 2019 - 06:19 PM

There is no need to quote the post above yours. Just use the big Reply button or the Fast Reply area. Also, please learn how to use code tags. It shows you right in the watermark how to do this.
Was This Post Helpful? 1
  • +
  • -

#8 JR360   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 27-September 19

Re: Data Analysis Question

Posted 17 October 2019 - 06:25 PM

View PostSkydiver, on 17 October 2019 - 06:19 PM, said:

There is no need to quote the post above yours. Just use the big Reply button or the Fast Reply area. Also, please learn how to use code tags. It shows you right in the watermark how to do this.

ahh thank you for the information im new using this website. in relation to my question is there any place where I can learn more about what I want to do with this code. your help will highly be appreciated.
Was This Post Helpful? 0
  • +
  • -

#9 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7135
  • View blog
  • Posts: 24,240
  • Joined: 05-May 12

Re: Data Analysis Question

Posted 17 October 2019 - 06:57 PM

I find it highly insulting that I just told you that there is no need to quote the post above yours, and told you how to avoid quoting, yet you just ignored that. So what use would be if I told you where you can learn more? Would you also ignore that?

Good luck with your quest to learn. I'm out.
Was This Post Helpful? 0
  • +
  • -

#10 JR360   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 27-September 19

Re: Data Analysis Question

Posted 17 October 2019 - 07:33 PM

skydiver, im so sorry I did not mean to write that, im new to this language and coding. I apologize if I was rude to you skydiver... I do want help with this code, please.
Was This Post Helpful? 0
  • +
  • -

#11 JR360   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 27-September 19

Re: Data Analysis Question

Posted 29 October 2019 - 03:09 PM

First, thank you for helping me with this code problem. the problem that I'm having with this code is that is not changing the numbers that have been chosen. this code what is doing is allowing you to choose a group of numbers and then mix them in different orders. so far no errors have appeared the problem is that I don't know how to mix the numbers in different order, I research a couple of things on C++ and, I found that you can put them in collection or array and sort then, but so far I have not learned how to use algorithm or collection of array and sort. so far I have not been able to figure it out it's so frustrating not being able to figure out.

okay this is an example of what I want to look like
EXAMPLE:
4, 10, 11, 15, 17
4 ,10, 11, 28, 53
4, 10, 15, 38, 53
4, 10, 19, 27, 49
4, 10, 28, 56, 57
4, 10, 32, 56, 57
4, 15, 19, 27, 49
11, 15, 19, 27, 59
11, 15, 28, 32, 53

So far this is what I have

#include <iostream>
#include <time.h>

using namespace std;

void choose(int a,int b,int c,int d[]);
void screen(int a[],int B)/>;

int main(){
    int plays;
    int numbers;
    int price=plays*2;
  
    
    choose(numbers,plays,price,playerNumbers);
    screen(playerNumbers,plays);
}

void choose(int a,int b,int c,int d[]){
    cout << "How many numbers? : ";
    cin >> a;
    cout << "How many plays? : ";
    cin >> b;
    cout << "That will cost " << c << endl;
    
    for(int i=1;i<=5;i++){
        cout << "Number" << i << ":";
        cin >> d[i];
    }
}

void screen(int a[],int B)/>{
    for(int i=1;i<=5;i++){
        cout << i;
        for(int j=0;j<5;j++){
            cout << "[" << a[j+1] << "]";
        }
        cout << endl;
    }
}

 

Was This Post Helpful? 0
  • +
  • -

#12 Salem_c   User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 2395
  • View blog
  • Posts: 4,529
  • Joined: 30-May 10

Re: Data Analysis Question

Posted 29 October 2019 - 11:20 PM

Is your example the input or the output?

You need better variable names than a,b,c,d if you want to understand things.
Staring at alphabet soup wont help you.

If you want a function to change a value in another function, then you need to use references.
void getPlayInfo(int &howmany, int &numplays ) {
    cout << "How many numbers? : ";
    cin >> howmany;
    cout << "How many plays? : ";
    cin >> numplays;
}
int main ( ) {
    int howmany, numplays;
    getPlayInfo(howmany,numplays);
    cout << howmany << "," << numplays << endl;
}


Was This Post Helpful? 0
  • +
  • -

#13 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7135
  • View blog
  • Posts: 24,240
  • Joined: 05-May 12

Re: Data Analysis Question

Posted 30 October 2019 - 05:15 AM

You already have a thread about this. Merging threads...
Was This Post Helpful? 1
  • +
  • -

#14 JR360   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 27-September 19

Re: Data Analysis Question

Posted 12 November 2019 - 05:26 PM

View PostSalem_c, on 29 October 2019 - 11:20 PM, said:

Is your example the input or the output?

You need better variable names than a,b,c,d if you want to understand things.
Staring at alphabet soup wont help you.

If you want a function to change a value in another function, then you need to use references.
void getPlayInfo(int &howmany, int &numplays ) {
    cout << "How many numbers? : ";
    cin >> howmany;
    cout << "How many plays? : ";
    cin >> numplays;
}
int main ( ) {
    int howmany, numplays;
    getPlayInfo(howmany,numplays);
    cout << howmany << "," << numplays << endl;
}



Hi, Salem_c can you use my code and change what you are talking about. I'm new to coding and I have no idea what you are saying about references, I will appreciate, please. also how did you learn about coding
#include <iostream>
#include <time.h>

using namespace std;

void choose(int a,int b,int c,int d[]);
void screen(int a[],int B)/>;

int main(){
    int plays;
    int numbers;
    int price=plays*2;
  
    
    choose(numbers,plays,price,playerNumbers);
    screen(playerNumbers,plays);
}

void choose(int a,int b,int c,int d[]){
    cout << "How many numbers? : ";
    cin >> a;
    cout << "How many plays? : ";
    cin >> b;
    cout << "That will cost " << c << endl;
    
    for(int i=1;i<=5;i++){
        cout << "Number" << i << ":";
        cin >> d[i];
    }
}

void screen(int a[],int B)/>{
    for(int i=1;i<=5;i++){
        cout << i;
        for(int j=0;j<5;j++){
            cout << "[" << a[j+1] << "]";
        }
        cout << endl;
    }
}




Was This Post Helpful? 0
  • +
  • -

Page 1 of 1