Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <time.h>
- using namespace std;
- int random(int min, int max)
- {
- static bool first = true;
- if (first)
- {
- srand( time(NULL) );
- first = false;
- }
- return min + rand() % (( max + 1 ) - min);
- }
- int main()
- {
- int m,n;
- int naj = -100;
- int ii=0,jj=0;
- cout<<"Program szuka najwiekszej liczby w tablicy dwuwymiarowej !"<<endl<<endl;
- cout<<"Podaj m: ";
- cin>>m;
- cout<<endl;
- cout<<"Podaj n: ";
- cin>>n;
- cout<<endl;
- //DEKLAROWANIE TABLICY
- int **tab = new int *[m];
- for(int i =0; i < n; i++)
- {
- tab[i] = new int [n];
- }
- //WYPELNIANIE
- for(int i = 0; i < m; i++)
- {
- for(int j = 0; j < n; j++)
- {
- tab[i][j] = random(0,200);
- }
- }
- cout<<endl;
- cout<<"Wygenerowana tablica:"<<endl;
- //WYPISANIE TABLICY
- for(int i = 0; i < m; i++)
- {
- for(int j = 0; j < n; j++)
- {
- cout<<tab[i][j]<<" ";
- }
- cout<<endl;
- }
- //SZUKANIE WARTOSCI NAJWIESKZEJ
- for(int i = 0; i < m; i++)
- {
- for(int j = 0; j < n; j++)
- {
- if(tab[i][j] > naj)
- {
- naj = tab[i][j];
- ii = i;
- jj = j;
- }
- }
- }
- cout<<"Wyniki: "<<endl;
- cout<<"Najwieksza liczba: "<<naj;
- cout<<endl<<"Pozycja wiersz: "<<ii<< " kolumna: "<<jj;
- return 0;
- }
- ---------
- #include <iostream>
- #include <cstdlib>
- #include <time.h>
- #include <string>
- using namespace std;
- bool isCyfra(string napis)
- {
- for(int i = 0; i < napis.length(); i++)
- {
- if(napis.at(i) >= '0' && napis.at(i) <= '9')
- return true;
- }
- return false;
- }
- int main()
- {
- int n;
- cout<<"Program wczytuje n napisow i rodziela !";
- cout<<endl;
- cout<<"Podaj n: ";
- cin>>n;
- cout<<endl;
- int i1=0,i2=0,i3=0;
- //DEKLAROWANIE TABLICY
- string **tab = new string *[3];
- for(int i =0; i < 3; i++)
- {
- tab[i] = new string [n];
- }
- //WPISYWANIE DO TABLICY
- for(int i = 0; i < n; i++)
- {
- string tmp;
- cin>>tmp;
- if(tmp.length() > 10)
- {
- tab[0][i1] = tmp;
- i1++;
- }
- if(tmp.at(0) >= 'A' && tmp.at(0) <= 'Z')
- {
- tab[1][i2] = tmp;
- i2++;
- }
- if(isCyfra(tmp))
- {
- tab[2][i3] = tmp;
- i3++;
- }
- }
- cout<<"Wyniki: "<<endl;
- for(int i = 0; i < 3; i++)
- {
- for(int j = 0; j < n; j++)
- {
- cout<<tab[i][j]<<" ";
- }
- cout<<endl;
- }
- return 0;
- }
- -----------
- #include <iostream>
- using namespace std;
- int horner(int wsp[],int st, int x)
- {
- if(st==0)
- return wsp[0];
- return x*horner(wsp,st-1,x)+wsp[st];
- }
- int main()
- {
- int *wspolczynniki;
- int stopien, argument;
- cout<<"Program oblicza wielomian n-stopnia !"<<endl<<endl;
- cout<<"Podaj stopien wielomianu: ";
- cin>>stopien;
- wspolczynniki = new int [stopien+1];
- for(int i=0;i<=stopien;i++)
- {
- cout<<"Podaj wspolczynnik stojacy przy potêdze "<<stopien-i<<": ";
- cin>>wspolczynniki[i];
- }
- cout<<"Podaj argument X: ";
- cin>>argument;
- cout<<"W( "<<argument<<" ) = "<<horner(wspolczynniki,stopien,argument)<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement