User: Tigureq

  • Public profile

User profile: Tigureq

User info
User name:Tigureq
Bio:#include <iostream>
#include <string>
#include <cstdlib>
#include <time.h>
#include <fstream>
using namespace std;

int losowanie(int tab,int min,int max,int index){
int range = max-min+1;
tab[index] = rand()%range+min;
return 0;
}

int znajdz_znok(char &znok,string &zrodlo){
int i = 0;
while(zrodlo[i]!=0){
if(zrodlo[i]==znok)
return i+1;
i++;
}
return -1;
}
int sprawdz_stringa(string a,string b){
if(a>b)cout<<"String a jest wiekszy od stringu b"<<endl;
if(b>a)cout<<"String b jest wiekszy od stringu a"<<endl;
if(a==b)cout<<"Stringi sa takie same"<<endl;

return 0;
}

int main(){
//zad1
int rozmiar=1;
cout<<"Podaj rozmiar tablicty do utworzenia: ";
cin>>rozmiar;
inttab;
tab = new int [rozmiar];
//zad2,3
srand(time(NULL));
for(int i =0;i<rozmiar;i++)
losowanie(tab,1,10,i);

for(int i =0;i<rozmiar;i++)
cout<<"Wylosowana liczba to: "<<tab[i]<<endl;

delete [] tab;
tab = nullptr;

//zad4.1
char znok1 = 'G';
string src = "Marson to Gedronin";

cout<<"Pozycja znaku "<<znok1<<" jest rowna: "<<znajdz_znok(znok1,src)<<endl;

//zad 4.2
string a = "Witaj marsonie";
string b = "Zegnaj marsonie";
sprawdz_stringa(a,b);


string zapis;
cout<<"Podaj dane do zapisania: ";
cin>>zapis;
ofstream plikosz("nazwa.txt");
plikosz<<zapis;

return 0;
}
History
Joined:
Number of posts:1
Latest posts:

Shinegatori
#include <iostream> #include <string> #include <cstdlib> #include <time.h> #include <fstream> u...

This user does not accept Private Messages