Peter, Simon und Daniel sollen zwei Zahlen herausfinden. Hierfür erhalten sie folgende Informationen: Beide Zahlen liegen im Bereich von 1 bis 1000, und beide sind ganzzahlig (also keine Kommazahlen), und es wäre auch möglich, dass beide Zahlen identisch sind. Peter erfährt zudem das Produkt der beiden Zahlen, Simon bekommt die Summe, und Daniel die Differenz.
Daraufhin kommt es zu folgendem Gespräch:
Peter: Ich kenne die Zahlen nicht.
Simon: Das brauchst Du mir nicht zu sagen, denn das wusste ich schon.
Peter: Dann kenne ich die Zahlen jetzt.
Simon: Ich kenne sie jetzt auch.
Daniel: Ich kenne die beiden Zahlen noch nicht. Ich kann nur eine Zahl vermuten, die wahrscheinlich dabei ist, aber sicher weiß ich's nicht.
Peter: Ich weiß, welche Zahl Du vermutest, aber die ist falsch.
Daniel: OK, dann kenne ich jetzt auch beide Zahlen.
das ist auf jeden fall lösbar! auf http://www.onlinewahn.de/ steht auch noch ein hinweis einfach mal auf rätsel spaß und dann die schwierigsten rätsel zahlenrätsel lg funsel

Liebe/r FunSel, gutefrage.net ist eine Ratgeber-Plattform und kein Rätsel-Forum. Deine Frage ist hier fehl am Platz. Bitte beachte künftig unsere Richtlinien unter http://www.gutefrage.net/policy. Deine Beiträge werden sonst gelöscht. Vielen Dank für Dein Verständnis! Schöne Grüße Jörg vom gutefrage.net-Support

für die lösung hat ein Spezialist folgendes Programm geschrieben: (ich kapiers aber nicht)
include<iostream> using namespace std;
class cell { public: int a; int b; int p; cell* next; cell* pre; };
void erzeugetabelle(cell*&, cell*&, unsigned); void quicksort(cell*, cell*); void tausche(cell*, cell*); void reduziere(cell*&, cell*&); void schreibelua(cell, cell, int); bool ist_in_liste(int, int, int=0, int=103359); void erzeugesummen(int*&, int*&); void reduzierep(cell, cell, int, int); void reduzieres(int*, int*, int*); void sortierediff(int); void reduziere_d(int, int); void checke_diff(int, int*);
int main() { cout<<"\n(1)\n p erzeugen ....... "; cell produkte; cell* ph1=&produkte; cell* ph2=0; erzeugetabelle(ph1, p_h2, 1000); cout<<"done\n";
cout<<" p sortieren ...... ";
quicksort(p_h1, p_h2);
cout<<"done\n";
cout<<" p reduzieren ..... ";
reduziere(p_h1, p_h2);
cout<<"done\n";
cout<<" p kopieren ....... ";
int lua[103360]={0};
int* p_lua=&lua[0];
schreibe_lua(p_h1, p_h2, p_lua);
cout<<"done\n";
cout<<"\n(2)\n s reduzieren ..... ";
int summen[235];
int* p_summen=&summen[0];
erzeuge_summen(p_lua, p_summen);
cout<<"done\n";
cout<<"\n(3)\n p reduzieren ..... ";
int prod[6984];
reduziere_p(&produkte, p_h2, &summen[0], &prod[0]);
cout<<"done\n";
cout<<"\n(4)\n s reduzieren ..... ";
int diff[81]={0};
reduziere_s(&summen[0], &prod[0], &diff[0]);
cout<<"done\n";
cout<<" d sortieren ...... ";
sortiere_diff(&diff[0]);
cout<<"done\n";
cout<<"\n(5)\n d reduzieren ..... ";
int diff_new[81]={0};
reduziere_d(&diff[0], &diff_new[0]);
cout<<"done\n";
cout<<"\n(6)+(7)\n d reduzieren ..... ";
int ergebnis[3]={0};
checke_diff(&diff_new[0], &ergebnis[0]);
cout<<"done\n";
cout<<"\n\n die gesuchten zahlen sind "<<ergebnis[1]<<" und "<<ergebnis[2]<<"\n";
}
void erzeugetabelle(cell*& p01, cell& p_02, unsigned n) { cell start=p01; p01->pre=0; p02=p01; for(int i=1; i<=n; ++i) { for(int j=1;j<=i; ++j) { p01->a=i; p01->b=j; p01->p=i*j; p01->next=new cell; p02=p01->next; p02->pre=p01; p01=p02; } } p01=start; p02=p02->pre; p02->next=0; }
void quicksort(cell* left, cell* right)
{
cell* l=left;
cell* r=right;
int pivot=(l->p+r->p);
while(l!=r)
{
while(r->p2>=pivot && l!=r)
{
r=r->pre;
}
while(l->p2<pivot && l!=r)
{
l=l->next;
}
tausche(l,r);
}
if(left!=l && l!=right)
{
quicksort(left,l);
}
if(r!=right)
{
quicksort(r->next,right);
}
}
void tausche(cell* l, cell* r) { if(l!=r) { int tmp=l->p; l->p=r->p; r->p=tmp;
tmp=l->a;
l->a=r->a;
r->a=tmp;
tmp=l->b;
l->b=r->b;
r->b=tmp;
}
}
void reduziere(cell& start, cell& end)
{
cell* pa=start;
cell* pb=pa->next;
cell* pc=pb->next;
if(pa->p!=pb->p) // listenanfang
{
while(pb->p!=pc->p && pc->next!=0)
{
pb=pc;
pc=pc->next;
}
tausche(pa,pb);
pa->next=pc;
pc->pre=pa;
pb=pc;
pc=pc->next;
}
while(pb!=end) // liste
{
if(pa->p!=pb->p && pb->p!=pc->p)
{
pa->next=pc;
pc->pre=pa;
pb=pc;
pc=pc->next;
}
else
{
pa=pb;
pb=pc;
pc=pc->next;
}
}
if(pa->p!=pb->p) // listenende
{
end=pa;
end->next=0;
}
}
void schreibe_lua(cell* start, cell* end, int* lua) { cell* help=start; cell* helper=start->next; lua[0]=start->p; int counter=1; while(helper!=end) { if(help->p!=helper->p) { lua[counter]=helper->p; ++counter; } help=helper; helper=helper->next; } }
bool istinliste(int a, int* list, int left, int right) { if(left==right) { if(list[left]==a) { return true; } else { return false; } } if(list[(left+right)/2]<a && list[(left+right)/2]!=0) { return istinliste(a, list, (left+right)/2+1, right); } else { return istinliste(a, list, left, (left+right)/2); } }
void erzeugesummen(int*& plua, int& p_sum) { int counter=0; bool test; for(int i=2; i<=2000; ++i) { test=true; for(int j=1; j<=i-j; ++j) { if(!ist_in_liste(j(i-j),plua)) { test=false; } } if(test) { psum[counter]=i; ++counter; } } }
void reduzierep(cell* t, cell* tend, int* s, int* p) { int tmp; int count=0; int counter=0; bool end=false; do { tmp=t->p; counter=0; while(t->p==tmp && !end) { if(istinliste(t->a+t->b, s, 0, 234)) { ++counter; } if(t==tend) { end=true; } else { t=t->next; } } if(counter==1) { p[count]=tmp; ++count; } } while(t!=tend); }
void reduzieres(int* s, int* p, int* d) { int tmp; int count=0; int counter=0; for(int i=0; i<235; ++i) { counter=0; for(int j=1; j<=s[i]-j; ++j) { if(istin_liste(j*(s[i]-j), p, 0, 6983)) { ++counter; if(counter==1) { tmp=j; } } } if(counter==1) { d[count]=s[i]-tmp-tmp; d[count+1]=tmp; d[count+2]=s[i]-tmp; count+=3; } } }
void sortierediff(int* d)
{
int tmp;
for(int i=2; i<27; ++i)
{
for(int j=0; j*3<=80-i*3; ++j)
{
if(d[j*3]>d[(j+1)*3])
{
for(int k=0; k<=2; ++k)
{
tmp=d[j*3+k];
d[j*3+k]=d[(j+1)*3+k];
d[(j+1)*3+k]=tmp;
}
}
}
}
}
void reduziered(int* do, int* dn)
{
int a,b,d,tmp,k,count=0;
bool doppelt;
int i=0;
while(i<=75)
{
if(do[i]!=do[i+3])
{
i+=3;
}
else
{
doppelt=false;
k=0;
d=do[i];
while(d==do[i+k])
{
a=do[i+k+1];
b=do[i+k+2];
tmp=i+k+3;
while(d==do[tmp] && tmp<=78)
{
if(do[tmp+1]==a || do[tmp+1]==b || do[tmp+2]==a || do[tmp+2]==b)
{
doppelt=true;
}
tmp+=3;
}
k+=3;
}
while(d==do[i] && i<=78)
{
if(doppelt)
{
dn[count]=do[i];
dn[count+1]=do[i+1];
dn[count+2]=do[i+2];
count+=3;
}
i+=3;
}
}
}
}
void checke_diff(int* d, int* e)
{
int i=0;
while(d[i]!=0)
{
if(d[i+1]==d[i+4] || d[i+2]==d[i+4] || d[i+1]==d[i+5] || d[i+2]==d[i+5])
{
e[0]=d[i+6];
e[1]=d[i+7];
e[2]=d[i+8];
}
else if(d[i+1]==d[i+7] || d[i+2]==d[i+7] || d[i+1]==d[i+8] || d[i+2]==d[i+8])
{
e[0]=d[i+3];
e[1]=d[i+4];
e[2]=d[i+5];
}
else
{
e[0]=d[i];
e[1]=d[i+1];
e[2]=d[i+2];
}
i+=9;
}
}
when he rolls up his sleeves he ain't just puttin' on the ritz ... ... our god is an awesome god! Offline
daniel Senior Member
Ort: boeblingen Registriert: 2002-05-03 Beiträge: 2065 Webseite Re: Zahlenrätsel... falls du irgendwelche erklaerungen zum code haben moechtest: einfach fragen!
ja ich auch nich^^
wow wie hast du das denn gelöst?!
frag ich mich jetzt auch....^^
ti 200 voyage und ja http://www.fairymail.de/dashammerhartezahlenraetsel_loesung.htm
und glaubt mir wer von programmieren keine ahnung hat bekommt es nie hin ;-) die seite gehört mir hatte die frage schon mal und hab sie onlne gestellt war auch eine aufgabe im Kurs
ah lol