473,378 Members | 1,389 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,378 software developers and data experts.

Conway Sequence

I have written a program to calculate the Conway Sequence (eg 3, 13, 1113, 3113, .....) which is:

#include <math.h>
#include <stdio.h>

int i[100000], f[100000];
int con, m, n, p, q, rept, count, r;

main()
{
for(n=0;n<100000;n++)
{
i[n] = 0;
f[n] = 0;
}
printf("Enter a number between 1 and 9: ");
scanf("%d",&i[0]);
printf("How many times do you want to run the sequence? ");
scanf("%d",&rept);
printf("%d\n",i[0]);
count = 0;
do{



m=0,p=0;

while(i[m] > 0)
{
if(i[m] == i[m+1])
{
r = 2;
m = m + 1;

while(i[m] == i[m+1])
{
r = r + 1;
m = m + 1;
}

f[p] = r;
f[p+1] = i[m-1];
m = m + 1;
p = p + 2;
}
else
{
f[p] = 1;
f[p+1] = i[m];

m = m+1;
p = p+2;
}

}
q = 0;
while(f[q]>0)
{
printf("%d",f[q]);
q=q+1;
}
printf("\n");

for(con=0;con<100000;con++)
{
i[con] = f[con];
}

count = count + 1;
}
while(count<rept);

}


It works fine, but i was wondering if i can make it to start with a number greater than 9, so a two or more digit number?
Please help, Thanks
Oct 22 '06 #1
0 1132

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

Similar topics

10
by: Anthony Best | last post by:
I'm working on an idea that uses sequences. I'm going to create a table like this: id serial, sequence int, keyword varchar(32), text text for every keyword there will be a uniq sequence...
5
by: Eric E | last post by:
Hi, I have a question about sequences. I need a field to have values with no holes in the sequence. However, the values do not need to be in order. My users will draw a number or numbers from...
3
by: kevin | last post by:
Is that even possible? I am creating a web service in .NET to expose some already created .NET programs to other groups. One group is writing the client in PERL, and thus wishes the wsdl schema...
8
by: regis | last post by:
Greetings, about scanf matching nonempty sequences using the "%" matches a nonempty sequence of anything except '-' "%" matches a nonempty sequence of anything except ']" matches a nonempty...
4
by: Putty | last post by:
Hi. I was going to write an implementation of John Conway's Life game using Python and Tk, but I soon found that Tk just didn't cut the mustard for memory usage, management, and the like for such...
14
by: pat270881 | last post by:
hello, I have to implement a sequence class, however the header file is predefined class sequence { public: // TYPEDEFS and MEMBER CONSTANTS
6
by: Defcon2030 | last post by:
<bHey, can someone help me with this? I've been working on it for a few days now, and my head's starting to spin... </b> // FILE:ex1_imp.cxx // // // // CLASS IMPLEMENTED: sequence (see ex1.h...
1
davydany
by: davydany | last post by:
Hey guys...a n00b Here for this site. I'm making a sequence class for my C++ class. And The thing is in the array that I have, lets say i put in {13,17,38,18}, when i see the current values for the...
5
by: Anan18 | last post by:
Hello sir, I'm supposed to Implement and Test the sequence Class Using a Fixed-Sized Array (Chapter 3), from Data Structures & Other objects using c++. The header file is provided, and so is a test...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.