// level 3 minsta storsta.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <time.h>
usingnamespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int minst,storst,i,slump[10];
srand(time(NULL));
for (i=0;i<10;i++)
{
slump[i]=rand()% 10 + 1;
cout<<slump[i]<<endl; // just there so I can check the biggest and the smallest number to compare if they match my biggest and smallest ints
}
minst=slump[0];
for (i=0;i<10;i++)
{
if (minst>slump[i])
{
minst=slump[i];
}
}
storst=slump[0];
for (i=0;i<10;i++)
{
if (storst<slump[0])
{
storst=slump[i];
}
}
cout<<"Det minsta v\x84rdet \x84r "<<minst<<" och det storsta v\x84rdet \x84r "<<storst<<endl;
getch();
}
I get the error that both smallest and biggest integers show the same value although that's not what I want. Please help!
#include <cstdlib>
#include <iostream>
int main()
{
char repeat = 'Y';
while (repeat == 'Y')
{
// your program goes here
std::cout << "Want to run again? Y = Yes, whatever else = No\n> ";
// std::cout.flush(); // just in case the message doesn't show for you
std::cin >> repeat;
}
system("PAUSE");
return EXIT_SUCCESS;
}