locked
C++ simple question! RRS feed

  • Question

  • Okay so i am trying to make a program to help me learn and see what I can do at this time!

    I am trying to make a string that has 2 variables on it

    ex:
     1card1
     2card1

    1card2
    2card2

    etc...

    [x]card[y] kind of thing

    so like how would you go about doing this? or will i have to do the long way around this?

    • Moved by litdev Saturday, October 24, 2015 3:45 PM
    Saturday, October 24, 2015 7:01 AM

Answers

  • Hi, joemdoo:

    There are some tips may help you:

    1. “[x]card[y]” includes some basic concepts. For example, string (if you want to store these strings and manipulate them by string manipulation), loop and etc.
    2. For the string manipulation, you could search key words like “Strings and String Manipulation in C++”, and you will find some examples or tutorials to learn.For the loop, of course, just search the key words like “loops in C++”Through these examples or tutorials, you could learn to write your own program. During the process of writing your program, if you have some problems, you could post the problem in the forum, all related questions are welcomed in our forum.
    3. Of course, systematic study will help you a lot.

    I write a sample below, and hope it’s helpful to you.

    #include "stdafx.h"
    #include<iostream>
    #include<string>
    using namespace std;
    
    int main(){    
    
    int numline=5;//numlne defines how many pairs to be showed 
       
    int firstnum[] = { 1,2 }; 
       
    for (int i = 1; i<numline; i++)    
    {        
    cout << firstnum[0] << "card" << i << endl;        
    cout << firstnum[1] << "card" << i << endl;        
    cout << '\n';    
    }    
    return 0;}
    
    
    Best regards,
    chchlll

    • Proposed as answer by chchlll Monday, November 2, 2015 6:14 AM
    • Marked as answer by Shu 2017 Tuesday, November 3, 2015 1:58 AM
    Monday, October 26, 2015 8:08 AM

All replies

  • Please ask this in a C++ forum. This one is about the Small Basic language.

    Jan [ WhTurner ] The Netherlands

    Saturday, October 24, 2015 2:22 PM
  • Okay so i am trying to make a program to help me learn and see what I can do at this time!

    I am trying to make a string that has 2 variables on it

    ex:
     1card1
     2card1

    1card2
    2card2

    etc...

    [x]card[y] kind of thing

    so like how would you go about doing this? or will i have to do the long way around this?

    Why don't you give it a try yourself.  If you can't get it to work you can post your code here on the forum where the community will be able provide helpful comments and suggestions for you.  You'll learn more if you "take the long way around this."
    Saturday, October 24, 2015 4:26 PM
  • Hi, joemdoo:

    There are some tips may help you:

    1. “[x]card[y]” includes some basic concepts. For example, string (if you want to store these strings and manipulate them by string manipulation), loop and etc.
    2. For the string manipulation, you could search key words like “Strings and String Manipulation in C++”, and you will find some examples or tutorials to learn.For the loop, of course, just search the key words like “loops in C++”Through these examples or tutorials, you could learn to write your own program. During the process of writing your program, if you have some problems, you could post the problem in the forum, all related questions are welcomed in our forum.
    3. Of course, systematic study will help you a lot.

    I write a sample below, and hope it’s helpful to you.

    #include "stdafx.h"
    #include<iostream>
    #include<string>
    using namespace std;
    
    int main(){    
    
    int numline=5;//numlne defines how many pairs to be showed 
       
    int firstnum[] = { 1,2 }; 
       
    for (int i = 1; i<numline; i++)    
    {        
    cout << firstnum[0] << "card" << i << endl;        
    cout << firstnum[1] << "card" << i << endl;        
    cout << '\n';    
    }    
    return 0;}
    
    
    Best regards,
    chchlll

    • Proposed as answer by chchlll Monday, November 2, 2015 6:14 AM
    • Marked as answer by Shu 2017 Tuesday, November 3, 2015 1:58 AM
    Monday, October 26, 2015 8:08 AM