I've been working on this program to get input letters to repeat certain amounts of ones and I want to get amounts of one repeats to add up. I'm not exactly getting an error, I just want to figure out how to go from here to get these one repeats into added up numbers. I've been working on a phase where I'm concentrating on the first output variables so that I can know what to do with the rest of them. Here is the code:
I want to get that last number into a variable. Not just that specific number, but I want to get the last number of any amount that happens. If someone could help me out with this, it would be greatly appreciated. Just focus on what is going on with the xone and n_one variables. Once this issue with that variable can be figured out, the rest of them will be.
I want the length of xone to be however many times word causes to cases to cause xone to equal 1. I want to know how many times one repeats in xone. I want to use the amount of repeats as multipliers. I want the amount of ones that xone repeats, to be put into its own variable. Once I can actually do that, I can do that to the rest of the variables. When I get how many ones that xtwo repeats, I'm going to use that amount to multiply by 2. There will also be xthree repeats to multiply by 3 and so on. That is what I want to do.
You can use the count algorithm with strings as well.
So you could use this to count the number of occurrences of a string within another string.
Does this make your task much easier?
You have given us your algorithm (method) of your program ( I am still not entirely clear on this) - just wondering what you are using the program to do? That is, what what is the real world use for your program? This might help us all suggest a good solution for you.
to cause xone to equal 1.
Are you using the value of 1 to mean true instead of a bool variable?
1 is being used as a repeater to determine numbers to multiply by in that variable. This is a kind of numerology program that I am working on. I have some ideas on how to use it for things like arranging colors and notes certain ways for meditations for example. I also want to build it into a video game. I want to do whatever I can think of doing with it. I think that I'm going to have to rearrange things with the input and output because of this series of while loops within while loops. I actually just figured out writing that last line into a text file. I figure that I should do some file linking, because of this repeat issue. I gotta keep this translator-repeater code in its own main in its own file, then link another cpp file to it with an h file. In the other cpp file, I should do a cin input with a char that I should add to the word char. In the same file, read the text files. Because the output number gets written into the text file that is being read, hopefully there wont be a linking issue. That would be another thing to deal with.
I am not getting it........ Probably because I don't understand anything about numerology.
In your original example, you had a string of 23 'a' characters as input. The output was the numbers 1 to 23.
You wanted to store the value 23 into a variable.
I don't see why you need 170 lines of code to do this.
The count algorithm can count the number of occurrences of the char 'a' in the input string.
I want to know how many times one repeats in xone.
This is counting the number of one's in xone isn't it? Maybe you could come up with better variable names?
I figured out how to get that. Now, I have to somehow get around the looping structure to make things not repeat like they do. I made it so that the amount of one repeats is stored in a text file. Now all I have to do is be able to read the text file and output its contents outside of the while loop structuring that makes things repeat.
I want the first basic input and output screen to look like this, pretty much:
Number Tree System
Enter a Name or a Word: Quantum
170.620.1.540.410.620.430
1 x 3 = 3;
7;
10 x 6 = 60 = 6;
6 x 2 = 12 = 3;
2 x 2 = 4;
5;
4 x 3 = 12 = 3;
6;
3;
I think the best thing to do here is to design your code by writing the methodology as comments. This can be done iteratively - start with general ideas, then go back and keep refining it, until you reach the point where you are happy to write code. Leave the comments in, as they serve as documentation.
This will help to organise things logically, identify functions, which control- flow methods (if, loops etc) to use, data structures and types to store info. Hopefully this will result in elegant and efficient code.
To start off, I came up with this:
1 2 3 4 5 6
//Convert characters in a word into number codes
//details of how to do this
//count occurrences of each digit in the number string - use count algorithm
//need to keep track of digits already counted and their position in the string
//mutilply count by digit = sum
//digital root function to add digits in sum
Right. The exact issue that I know that I need to get passed, is a looping and output issue. I got the number that I need to write into a text file. NOW, all I need to do is find the right way to get that number from the text file into a variable in the same file. Once I can get that done right, I know what I need to do from there. I've had most of the general math methods planned out while also knowing that I had to work out some issues along the way. Functional issues. I recently included cmath and after the count++ I replaced that previous code with this code instead:
Those alterations successfully write to xone.txt when you have that file in an include directory in the compiler settings. Now that that works, I want to figure out how to read from the text file and work with the number, then work with all the variables like that. This is the code that I plan on using somewhere to read from the text file:
1 2 3 4
std::ifstream input("xone.txt");
int x1;
input >> x1;
cout << x1;
All I gotta do is figure out where and how to execute that code to read from the text file correctly and work with the number correctly without the loops doing things to it that are against the objectives.
I don't see the point in writing the value of a variable to a file, only to read it in again into another variable.
Why not just assign it to the new variable?
All I gotta do is figure out where and how to execute that code to read from the text file correctly and work with the number correctly without the loops doing things to it that are against the objectives.
I hope you are not trolling by being overly pedantic. I have made a number of posts and we don't seem to be getting very far.
The point of transferring through a file is getting the amount values for multipliers in this loop . It is the only way I could do it. I tried what you just suggested to me and it did not work, because of the loop. I can get the numbers I want through to a display now. I ran into a new problem so far. I'm using multiple counts and they are interfering with each other.
I took this project a whole other direction with strings. Now all I gotta do is figure out how to allocate enough memory to make it so the exe doesn't crash.