• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Jun 24th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. string s=""; // declari un string
2. int v[15];  // declari un vector de aparitii
3. for(int i = 0;i <= 9;i++) // setezi toate valorile vectorului 0
4.     v[i] = 0;
5.
6. for(int i = 0;i < n;i++){// cand faci citirea
7.     char Ch;
8.     cin >> Ch;//citesti charul
9.     if(Ch >= '0' && Ch <= '9'){//verifici daca e cifra
10.         if(v[Ch - '0'] == 0)
11.             v[Ch - '0'] = 1;//incremetezi vectorul ex : '0' are ascii 48 ,tu vrei sa incrementezi v[0] deci scazi '0'.Pt '1' avem ascii 49 si scadem '0' care vine v[1]
12.     }else{
13.         s += Ch; // altfel adaugam in string charul curent
14.     }
15. }
16. cout << s << '\n'; // afisezi stringul
17.
18. for(int i = 0;i < 10;i++)//afisezi cifrele care au v[index] = 1
19.     if(v[i] == 1)
20.         cout << i;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top