Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- int tab[5];
- int x, suma_cyfr, reszta;
- suma_cyfr=0;
- cin>>x;
- for(int i=0;i<5;i++)
- {
- tab[i]=(std::rand()%12)+1;
- }
- cout<<endl<<tab[0]<<endl<<tab[1]<<endl<<tab[2]<<endl<<tab[3]<<endl<<tab[4]<<endl;
- for(int i=0; i<5; i++)
- {
- if(tab[i]==x)
- {
- cout<<"Liczba jest w tablicy, jej indeks to"<<i+1;
- while(x!=0)
- {
- reszta=x%10;
- x=x/10;
- suma_cyfr+=reszta;
- cout<<"Jej suma cyfr to:"<<suma_cyfr<<endl;
- }
- }
- }
- cout<<"Liczby nie ma w tablicy";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement