<?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[Zahlenausgeber]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich soll ein Programm schreiben, wo der Benutzer 10 Zahlen eingaben kann und das Programm dann die größte und kleinste ausgibt!<br />
Könnt ihr mir helfen?</p>
<p>Danke schonmal</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/293277/zahlenausgeber</link><generator>RSS for Node</generator><lastBuildDate>Sun, 16 Aug 2026 10:44:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/293277.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 29 Sep 2011 10:57:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Zahlenausgeber on Thu, 29 Sep 2011 10:57:40 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich soll ein Programm schreiben, wo der Benutzer 10 Zahlen eingaben kann und das Programm dann die größte und kleinste ausgibt!<br />
Könnt ihr mir helfen?</p>
<p>Danke schonmal</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2125015</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2125015</guid><dc:creator><![CDATA[Dennis1995]]></dc:creator><pubDate>Thu, 29 Sep 2011 10:57:40 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlenausgeber on Thu, 29 Sep 2011 11:00:37 GMT]]></title><description><![CDATA[<p>Dennis1995 schrieb:</p>
<blockquote>
<p>Könnt ihr mir helfen?</p>
</blockquote>
<p><a href="http://www.c-plusplus.net/forum/200753" rel="nofollow">Du brauchst Hilfe?</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2125016</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2125016</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 29 Sep 2011 11:00:37 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlenausgeber on Thu, 29 Sep 2011 11:03:10 GMT]]></title><description><![CDATA[<p>Ich möchte dir nicht auf die Füsse tretten aber so wird dir bestimmt keiner Helfen. Du musst schon selbst etwas machen und heir posten. Anschließend können wir auf die einzelnen Sachen eingehen was gut und was nicht so tolle ist.</p>
<p>UND das was du haben möchtest braucht man kein INFO Studium <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2125019</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2125019</guid><dc:creator><![CDATA[J.Wayne]]></dc:creator><pubDate>Thu, 29 Sep 2011 11:03:10 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlenausgeber on Thu, 29 Sep 2011 14:04:57 GMT]]></title><description><![CDATA[<p>edit: Jetzt, wo ganz einfache Lösungen erscheinen, lösche ich meinen Versuch lieber wieder.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2125020</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2125020</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 29 Sep 2011 14:04:57 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlenausgeber on Thu, 29 Sep 2011 11:06:11 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

int main()
{
    const unsigned int ANZAHL = 10;
    int max = 0;
    int min = 0;

    int tmp;
    cin &gt;&gt; tmp;
    max = min = tmp;

    for(unsigned i = 1; i &lt; ANZAHL; ++i)
    {
        cin &gt;&gt; tmp;
        if ( tmp &gt; max )
            max = tmp;
        else if ( tmp &lt; min )
            min = tmp;
    }

    cout &lt;&lt; &quot;Min: &quot; &lt;&lt; min &lt;&lt; &quot; Max: &quot; &lt;&lt; max &lt;&lt; endl;
    return 0x0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2125022</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2125022</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Thu, 29 Sep 2011 11:06:11 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlenausgeber on Thu, 29 Sep 2011 11:25:54 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;algorithm&gt;
#include &lt;array&gt;

int main()
{
    const int number_of_numbers = 10;
    std::array&lt;int, number_of_numbers&gt; numbers;

    for(int i = 0; i &lt; number_of_numbers; ++i)
    {
        int n;
        std::cin &gt;&gt; n;
        numbers[i] = n;
    }

     auto minmax = std::minmax_element(numbers.begin(), numbers.end());
     std::cout &lt;&lt; &quot;min: &quot; &lt;&lt; *minmax.first  &lt;&lt; '\n'
               &lt;&lt; &quot;max: &quot; &lt;&lt; *minmax.second &lt;&lt; '\n';
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2125033</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2125033</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Thu, 29 Sep 2011 11:25:54 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlenausgeber on Thu, 29 Sep 2011 12:05:54 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">int min, max, zahl;
cin&gt;&gt;zahl;
min = max = zahl;
for (int i=2; i&lt;=10; ++i){
   cin &gt;&gt; zahl;
   min = std::min(min, zahl);
   max = std::max(max, zahl);
}
cout&lt;&lt;&quot;max=&quot;&lt;&lt;max&lt;&lt;'\n';
cout&lt;&lt;&quot;min=&quot;&lt;&lt;min&lt;&lt;'\n';
</code></pre>
<p>BTW:</p>
<p>314159265358979 schrieb:</p>
<blockquote>
<p>&lt;blödsinn&gt;</p>
</blockquote>
<p>Gehts auch mit noch mehr Speicherverbrauch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2125053</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2125053</guid><dc:creator><![CDATA[blödsinn]]></dc:creator><pubDate>Thu, 29 Sep 2011 12:05:54 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlenausgeber on Thu, 29 Sep 2011 12:10:30 GMT]]></title><description><![CDATA[<p>Gerne, ersetz array durch deque. Und mach aus int long long.<br />
Aber ich kann dich beruhigen, ich war gerade auf der Suche nach einer Lösung mit std::istream_iterator.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2125055</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2125055</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Thu, 29 Sep 2011 12:10:30 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlenausgeber on Thu, 29 Sep 2011 12:15:51 GMT]]></title><description><![CDATA[<p>314159265358979 schrieb:</p>
<blockquote>
<p>Aber ich kann dich beruhigen, ich war gerade auf der Suche nach einer Lösung mit std::istream_iterator.</p>
</blockquote>
<p>Das dumme an denen ist, das es trivial ist, mit einer beliebigen Menge von Eingaben zurecht zu kommen, wohingegen die Anforderung genau 10 Werte zu nehmen recht umständlich zu bauen ist. Schade, dass die Lehrer immer so konkrete Zahlen vorgeben <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> . Das erschwert allgemeine Lösungen und verführt dazu, mit statischen Arrays zu arbeiten. Vermutlich denken, sie, sie machten die Aufgabe dadurch leichter.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2125061</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2125061</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 29 Sep 2011 12:15:51 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlenausgeber on Thu, 29 Sep 2011 12:16:08 GMT]]></title><description><![CDATA[<p>Genau darüber habe ich gerade nachgedacht, aber ich bastle an einer Lösung <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2125063</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2125063</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Thu, 29 Sep 2011 12:16:08 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlenausgeber on Thu, 29 Sep 2011 12:20:49 GMT]]></title><description><![CDATA[<p>Das dumme an denen ist, das es trivial ist, mit einer beliebigen Menge von Eingaben zurecht zu kommen, wohingegen die Anforderung genau 10 Werte zu nehmen recht umständlich zu bauen ist.[/quote]Das zeigt, wie unflexibel die Standardlib ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2125067</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2125067</guid><dc:creator><![CDATA[blödsinn]]></dc:creator><pubDate>Thu, 29 Sep 2011 12:20:49 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlenausgeber on Thu, 29 Sep 2011 12:47:10 GMT]]></title><description><![CDATA[<p>blödsinn schrieb:</p>
<blockquote>
<p>Das dumme an denen ist, das es trivial ist, mit einer beliebigen Menge von Eingaben zurecht zu kommen, wohingegen die Anforderung genau 10 Werte zu nehmen recht umständlich zu bauen ist.</p>
</blockquote>
<p>Das zeigt, wie unflexibel die Standardlib ist.[/quote]</p>
<p><div class="plugin-markdown"><input type="checkbox" id="checkbox64682" /><label for="checkbox64682">Du hast Ahnung von was du schreibst</label></div></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2125075</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2125075</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Thu, 29 Sep 2011 12:47:10 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlenausgeber on Thu, 29 Sep 2011 12:56:35 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;iterator&gt;
#include &lt;algorithm&gt;
#include &lt;utility&gt;

template &lt;typename Iterator&gt;
class take_n_iterator : public std::iterator&lt;typename Iterator::value_type, typename Iterator::iterator_category&gt;
{
        unsigned n;
        Iterator iter;

public:
        template &lt;typename... Args&gt;
        explicit take_n_iterator(unsigned n, Args&amp;&amp;... args)
                : n(n)
                , iter(std::forward&lt;Args&gt;(args)...)
        {}

        take_n_iterator()
                : n(static_cast&lt;unsigned&gt;(-1))
        {}

        take_n_iterator&amp; operator ++ ()
        {
                --n;
                ++iter;

                return *this;
        }

        take_n_iterator operator ++ (int)
        {
                take_n_iterator tmp(*this);

                --n;
                ++iter;

                return tmp;
        }

        typename Iterator::reference operator * ()
        {
                return *iter;
        }

        friend bool operator == (const take_n_iterator&lt;Iterator&gt;&amp; lhs, const take_n_iterator&lt;Iterator&gt;&amp; rhs)
        {
                return (!lhs.n &amp;&amp; rhs.n == static_cast&lt;unsigned&gt;(-1)) || lhs.n == rhs.n;
        }

        friend bool operator != (const take_n_iterator&lt;Iterator&gt;&amp; lhs, const take_n_iterator&lt;Iterator&gt;&amp; rhs)
        {
                return !(lhs == rhs);
        }
};

int main()
{
        auto minmax = std::minmax_element(take_n_iterator&lt;std::istream_iterator&lt;int&gt;&gt;(10, std::cin), take_n_iterator&lt;std::istream_iterator&lt;int&gt;&gt;());

        std::cout &lt;&lt; &quot;min: &quot; &lt;&lt; *minmax.first  &lt;&lt; '\n'
                  &lt;&lt; &quot;max: &quot; &lt;&lt; *minmax.second &lt;&lt; '\n';
}
</code></pre>
<p>Yay.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2125081</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2125081</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Thu, 29 Sep 2011 12:56:35 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlenausgeber on Thu, 29 Sep 2011 13:15:13 GMT]]></title><description><![CDATA[<p>Ach jetzt warst du schneller. Aber ich hatte auch Lust bekommen:</p>
<pre><code class="language-cpp">#include &lt;iterator&gt;

template &lt;typename it_type&gt; class counting_istream_iterator: 
  public std::iterator&lt;std::input_iterator_tag, 
                       typename it_type::value_type, 
                       typename it_type::difference_type, 
                       typename it_type::pointer, 
                       typename it_type::reference&gt;
{
  typedef counting_istream_iterator&lt;it_type&gt; self_type;
  typedef std::iterator&lt;std::input_iterator_tag, 
                       typename it_type::value_type, 
                       typename it_type::difference_type, 
                       typename it_type::pointer, 
                       typename it_type::reference&gt;       base_type;
  it_type original;
  it_type current;
  typename base_type::difference_type counter;
public:
  typedef typename it_type::char_type char_type;
  typedef typename it_type::traits_type traits_type;
  typedef typename it_type::istream_type istream_type;

  counting_istream_iterator(it_type const &amp;it, typename base_type::difference_type const &amp;init):
    original(it),
    current(it),
    counter(init)
  {}

  friend bool operator==(self_type const&amp; lhs, self_type const&amp;rhs)
  { return (lhs.original == rhs.original) and (lhs.counter == rhs.counter); }
  friend bool operator!=(self_type const&amp; lhs, self_type const&amp;rhs)
  { return !(lhs == rhs); }

  self_type&amp; operator++() 
  {
    ++current;
    ++counter;
    return *this;
  }
  self_type&amp; operator++(int)
  {
    self_type tmp = *this;
    ++*this;
    return tmp;
  }

  const typename base_type::reference operator*() const {return *current;}
  const typename base_type::pointer operator-&gt;() const {return &amp;*current;}
};

#include &lt;iostream&gt;
#include &lt;algorithm&gt;
using namespace std;

void foo (int i) 
{
  cout &lt;&lt; &quot; &quot; &lt;&lt; i;
}

int main()
{
  typedef istream_iterator&lt;int&gt; it_type;
  typedef counting_istream_iterator&lt;it_type&gt; c_it_type;

  it_type cin_it(cin);
  for_each(c_it_type(cin_it, 0), c_it_type(cin_it, 10), foo);
}
</code></pre>
<p>War doch ganz einfach <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2125089</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2125089</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 29 Sep 2011 13:15:13 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlenausgeber on Thu, 29 Sep 2011 20:32:34 GMT]]></title><description><![CDATA[<p>.. und das ganze noch mal mit boost:</p>
<pre><code class="language-cpp">#include &lt;boost/iterator/iterator_adaptor.hpp&gt;
#include &lt;iterator&gt; // std::istream_iterator
#include &lt;iostream&gt;
#include &lt;utility&gt; // std::pair

template&lt; typename T &gt;
class CountingIstream : public boost::iterator_adaptor&lt; CountingIstream&lt; T &gt;, std::istream_iterator&lt; T &gt; &gt;
{
public:
    explicit CountingIstream( std::istream&amp; in )
        : iterator_adaptor_( in )
        , m_count( 0 )
    {}
    explicit CountingIstream( int count = -1 )
        : iterator_adaptor_()
        , m_count( count )
    {}
    void increment()
    {
        ++base_reference();
        ++m_count;
    }
    bool equal( const CountingIstream&amp; b ) const
    {
        return m_count == b.m_count || base() == b.base();
    }
private:
    int m_count;
};

// -- für alle, die noch nicht über den neuen Standard verfügen
template&lt; typename I &gt;
std::pair&lt; I, I &gt; minmax_element( I first, I last )
{
    I foundMin = first;
    I foundMax = first;
    if( first != last )
    {
        while( ++first != last )
        {
            if( *first &lt; *foundMin )
                foundMin = first;
            if( *foundMax &lt; *first )
                foundMax = first;
        }
    }
    return std::make_pair( foundMin, foundMax );
}

int main()
{
    using namespace std;
    const int N = 10;
    cout &lt;&lt; &quot;Geben Sie &quot; &lt;&lt; N &lt;&lt; &quot; Zahlen und ein 'x' ein&quot; &lt;&lt; endl;
    const pair&lt; CountingIstream&lt; int &gt;, CountingIstream&lt; int &gt; &gt; res
        = minmax_element( CountingIstream&lt; int &gt;( cin ), CountingIstream&lt; int &gt;( N ) );
    if( res.first != CountingIstream&lt; int &gt;() )
        cout &lt;&lt; &quot;Die kleinste Zahl war: &quot; &lt;&lt; *res.first &lt;&lt; &quot; und die groesste &quot; &lt;&lt; *res.second &lt;&lt; endl;
    return 0;
}
</code></pre>
<p>und dem kleinen Schönheitsfehler, dass am Ende noch mal eine nicht leere Zeile eingegeben werden muss, deren Inhalt aber keine Rolle spielt. Daher das &quot;und ein 'x'&quot;. Das folgt aus der Eigenheit des std::istream_iterators.</p>
<p>SeppJ schrieb:</p>
<blockquote>
<p>Das dumme an denen ist, das es trivial ist, mit einer beliebigen Menge von Eingaben zurecht zu kommen, wohingegen die Anforderung genau 10 Werte zu nehmen recht umständlich zu bauen ist. Schade, dass die Lehrer immer so konkrete Zahlen vorgeben <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> . Das erschwert allgemeine Lösungen und verführt dazu, mit statischen Arrays zu arbeiten. Vermutlich denken, sie, sie machten die Aufgabe dadurch leichter.</p>
</blockquote>
<p>so isses!</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2125284</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2125284</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Thu, 29 Sep 2011 20:32:34 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlenausgeber on Fri, 30 Sep 2011 06:55:11 GMT]]></title><description><![CDATA[<blockquote>
<p>Das dumme an denen ist, das es trivial ist, mit einer beliebigen Menge von Eingaben zurecht zu kommen, wohingegen die Anforderung genau 10 Werte zu nehmen recht umständlich zu bauen ist. Schade, dass die Lehrer immer so konkrete Zahlen vorgeben <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> . Das erschwert allgemeine Lösungen und verführt dazu, mit statischen Arrays zu arbeiten. Vermutlich denken, sie, sie machten die Aufgabe dadurch leichter.</p>
</blockquote>
<p>Naja, angenommen eine 0 signalisiert das Ende der Eingabe, würde doch auch nichts einfacher machen, oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2125353</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2125353</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Fri, 30 Sep 2011 06:55:11 GMT</pubDate></item><item><title><![CDATA[Reply to Zahlenausgeber on Fri, 30 Sep 2011 08:34:02 GMT]]></title><description><![CDATA[<p>Ethon schrieb:</p>
<blockquote>
<p>Naja, angenommen eine 0 signalisiert das Ende der Eingabe, würde doch auch nichts einfacher machen, oder?</p>
</blockquote>
<p>Nein, warum sollte es? Null ist nix besonderes. Aber wenn man sagen würde, dass man Zahlen bis zum Ende des Streams lesen soll, dann wäre es (wie viele Anfängerprobleme) ein typischer STL-Algorithms Zweizeiler.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2125393</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2125393</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 30 Sep 2011 08:34:02 GMT</pubDate></item></channel></rss>