<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Hashing: Programmabsturtz!]]></title><description><![CDATA[<p>ich will aus eine verk. liste ein knoten via hashing löschen..leider<br />
stürtzt das programm bei der delete eingabe ab!<br />
leider finde ich frn fehler nicht..kann mir jemand helfen?</p>
<pre><code class="language-cpp">const int M=3;

struct knoten			
{
	int wert;					
	struct knoten *next;		
} *H[M];			

int h(int wert) 
{
	return wert%M;
}

void add(int wert)					
{			
	struct knoten *aktuell = new knoten;	
	aktuell-&gt;wert = wert;					
	aktuell-&gt;next = NULL;				

	int i = h(wert);

	if (H[i] == NULL)						
	{ 
		H[i]=aktuell;
	}
	else								
	{ 
		aktuell-&gt;next = H[i];				
		H[i] = aktuell;					
	}
}

struct knoten * isMember(int wert)
{
	struct knoten *aktuell;
	aktuell = H[h(wert)];
	while (aktuell != NULL  &amp;&amp; aktuell-&gt;wert != wert)
		aktuell = aktuell-&gt;next;
	return aktuell;
}

void del(int wert)
{
	struct knoten *aktuell;
	aktuell = isMember(wert);
	if (aktuell != NULL)
	{
		struct knoten *tmp = H[h(wert)];
		while (tmp-&gt;next != aktuell)
		{
			tmp = tmp-&gt;next;
			tmp -&gt;next = aktuell-&gt;next;
			delete aktuell;
		}
	}
}

void main()
{	
	int wert;

	while (true) 
	{
		cout &lt;&lt; &quot;Integer (abort with neg. value): &quot;;
		cin &gt;&gt; wert;
		if (wert&lt;0) break;
		add(wert);
	}

	cout &lt;&lt; &quot;Integer to delete: &quot;;
	cin &gt;&gt; wert;
	del(wert);

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/136129/hashing-programmabsturtz</link><generator>RSS for Node</generator><lastBuildDate>Sat, 29 Aug 2026 07:21:58 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/136129.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 07 Feb 2006 14:59:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Hashing: Programmabsturtz! on Tue, 07 Feb 2006 14:59:33 GMT]]></title><description><![CDATA[<p>ich will aus eine verk. liste ein knoten via hashing löschen..leider<br />
stürtzt das programm bei der delete eingabe ab!<br />
leider finde ich frn fehler nicht..kann mir jemand helfen?</p>
<pre><code class="language-cpp">const int M=3;

struct knoten			
{
	int wert;					
	struct knoten *next;		
} *H[M];			

int h(int wert) 
{
	return wert%M;
}

void add(int wert)					
{			
	struct knoten *aktuell = new knoten;	
	aktuell-&gt;wert = wert;					
	aktuell-&gt;next = NULL;				

	int i = h(wert);

	if (H[i] == NULL)						
	{ 
		H[i]=aktuell;
	}
	else								
	{ 
		aktuell-&gt;next = H[i];				
		H[i] = aktuell;					
	}
}

struct knoten * isMember(int wert)
{
	struct knoten *aktuell;
	aktuell = H[h(wert)];
	while (aktuell != NULL  &amp;&amp; aktuell-&gt;wert != wert)
		aktuell = aktuell-&gt;next;
	return aktuell;
}

void del(int wert)
{
	struct knoten *aktuell;
	aktuell = isMember(wert);
	if (aktuell != NULL)
	{
		struct knoten *tmp = H[h(wert)];
		while (tmp-&gt;next != aktuell)
		{
			tmp = tmp-&gt;next;
			tmp -&gt;next = aktuell-&gt;next;
			delete aktuell;
		}
	}
}

void main()
{	
	int wert;

	while (true) 
	{
		cout &lt;&lt; &quot;Integer (abort with neg. value): &quot;;
		cin &gt;&gt; wert;
		if (wert&lt;0) break;
		add(wert);
	}

	cout &lt;&lt; &quot;Integer to delete: &quot;;
	cin &gt;&gt; wert;
	del(wert);

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/988596</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/988596</guid><dc:creator><![CDATA[brainwave81]]></dc:creator><pubDate>Tue, 07 Feb 2006 14:59:33 GMT</pubDate></item></channel></rss>