I'm having a bit of an issue with my solution to Euler problem 22. I have a list of names that are surrounded by quotation makes and separated by commas (I.E. "MARY",). I have created a function...
Type: Posts; User: deadrabbit
I'm having a bit of an issue with my solution to Euler problem 22. I have a list of names that are surrounded by quotation makes and separated by commas (I.E. "MARY",). I have created a function...
#include <stdio.h>
int main()
{
int dat[20][20] = {
{8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5 ,7 ,78 ,52 ,12 ,50 ,77 ,91 ,8},
{49 ,49 ,99 ,40 ,17 ,81 ,18 ,57 ,60 ,87 ,17 ,40 ,98 ,43 ,69...
I reworked the problem using these optimizations for the algorithm and the results were far more acceptable. However, I suppose its good to get a handle on threads sooner than later.
Thank you cas and anduril, for your advice. I will look into pthread_join() and implementing mutexes. Anduril, I wasn't sure how to do a loop when initializing the threads to call different...
I'm trying to implement threads with Project Euler problem 10. I am getting different results for the sum of the primes every time I run the program. I realize the code is quite atrocious; this is my...
I have the path to an MP3 stored in an array and would like to append it to a command passed to system().
system("mplayer FILE")
How might I be able to enumerate the contents of the...
I'm having a bit of trouble solving this problem. The objective is to find the largest product of five consecutive digits in this 1,000 digit number.
#include <stdio.h>
int main(void)
{...
Thanks Salem, that sorted it.
#include <stdio.h>
#include <string.h>
int main(void)
{
char *num = "73167176531330624919225119674426574742355349194934\
96983520312774506326239578318016984801869478851843\...
I wrote a program to find the largest palindromic number one could produce as the product of two three digit numbers.
int main (void)
{
int i, j, z;
int num;
char buf[6];
char...
I figured it out; were swapping the first and last elements, then second and second to last element, etc. which means that we only need to go half way through the array to reverse the elements.
It is supposed to reverse the contents of an array, that is take 4689 and turn it into 9864, using XOR operations.
I found the algorithm here...
I found this algorithm to reverse the contents of an array-
int len=strlen(word);
for (int i=0;i<len/2;i++)
{
word[i]^=word[len-i-1];
word[len-i-1]^=word[i];
...
Ahh, I see. Thank you all.
I wrote a program which should compute the sum of all of the multiples of 3 or 5 below 1,000.
int main()
{
int sum = 0;
int i;
for (i=0; i < 1000; i++)
{
Thanks! That fixed things up.:biggrin:
More of less on a whim I decided to write a program to convert matrices into row echelon form. To start off, I wrote a program that took numbers from the user and wrote them into a matrix, then...
Duly noted
AndrewHunter, an algorithm like that sounds a little bit out of my depth at the moment :(; I will look into sleep system calls as CommonTater suggested. Im running FreeBSD 8.2 and I compile with gcc...
Ive written an alarm clock program which now function as it should. However, when I look at the process list in top, I see that the alarm program is using 100% of one of my processor cores capacity....
Alright, thanks guys. I knew I was making this more complicated then it should be. :rolleyes:
I am writing an alarm clock program. Basically, it takes a time from the user and converts the difference between that time and the current into seconds. However, this function only returns the...
Thanks KCfromNC, that helped to clarify things for me somewhat :cool:
I am attempting to write a alarm clock which receives input from the user. My initial design was to have the user fill out the tm structure by hand. I found two different examples of this and am a...