Recent content by kheiron1729
-
K
C-language: quick n00b question
int main() { int n; char ch; char* str; int i; printf("Enter the number of values you want to enter in your string: "); scanf("%d", &n); str = (char*)malloc(sizeof(char)*n); printf("Enter the string: "); getchar(); fgets(str, n, stdin)...- kheiron1729
- Thread
- Replies: 1
- Forum: Engineering and Comp Sci Homework Help
-
K
3n+1 Problem from Programming Challenges
Thanks a bunch Grep. You are a life saver.- kheiron1729
- Post #8
- Forum: Engineering and Comp Sci Homework Help
-
K
3n+1 Problem from Programming Challenges
My friend shared his code with me. #include <iostream> using namespace std; int length(int n) { int i = 1; while(n != 1) { if(n % 2 == 0) { n /= 2; } else { n *= 3; n += 1; } i++; } return i; } int main() { int a, b, low, high; while(cin>>a>>b) { if(a < b) {...- kheiron1729
- Post #6
- Forum: Engineering and Comp Sci Homework Help
-
K
3n+1 Problem from Programming Challenges
First of all- Thanks a lot you guys! got it! I corrected the first problem. Not really a problem but oh well... I feel stupid. I have no idea why I did that. You're right! I was using Visual 2005. I don't think it even gave me a warning. I put this in DEV-C++ and it gives me nothing...- kheiron1729
- Post #5
- Forum: Engineering and Comp Sci Homework Help
-
K
3n+1 Problem from Programming Challenges
Hello. I am new here. Here is the question: Consider the following algorithm to generate a sequence of numbers. Start with an integer n. If n is even, divide by 2. If n is odd, multiply by 3 and add 1. Repeat this process with the new value of n, terminating when n = 1. For example, the...- kheiron1729
- Thread
- Programming
- Replies: 7
- Forum: Engineering and Comp Sci Homework Help