Street Numbers

ssendu Messages postés 6 Statut Membre -  
 McFly -
Hello,

I did a c program to solve this problem: A computer programmer lives in a street with houses numbered consecutively (from 1) down one side of the street. Every evening she walks her dog by leaving her house and randomly turning left or right and walking to the end of the street and back. One night she adds up the street numbers of the houses she passes (excluding her own). The next time she walks the other way she repeats this and finds, to her astonishment, that the two sums are the same. Although this is determined in part by her house number and in part by the number of houses in the street, she nevertheless feels that this is a desirable property for her house to have and decides that all her subsequent houses should exhibit it.

Could any one of you help me solve my problem??

Here is my peace of code
#include <stdio.h>

int main()
{
long sum1=15;
long sum2=0;
long x=0;
long limit=0;
for(x=6,limit=8;;){
sum1+=x;

int j=0;
for(j=limit;;){
sum2+=j;
if(sum1==sum2)
printf("%10d%10d\n", x+1, limit+1);
else if (sum2>sum1){
x=x+1;
limit=limit+1;

}
else
j++;

}

}

return 0;
}

1 réponse

McFly
 
First: it is a french forum so speak in french please.
Second: here we don't work for you but only help you. Explain his problem is easy but we are not pay to do your work. Show us a begining of programm; it will show that you ever work on your problem.
0