Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- Online C++ Compiler.
- Code, Compile, Run and Debug C++ program online.
- Write your code in this editor and press "Run" button to compile and execute it.
- *******************************************************************************/
- #include <iostream>
- using namespace std;
- int a, nizin[100], nizout[1000], br = 1, nizcount=0;
- string x;
- int main()
- {
- cin>>a;
- for(int i = 0; i < a; i++){
- cin>>nizin[i];
- x+=to_string(nizin[i]);
- }
- char temp = x[0];
- for(int i = 1; i < x.length(); i++){
- if(x[i] == temp){
- br++;
- } else {
- nizout[nizcount] = temp-48;
- nizcount++;
- nizout[nizcount] = br;
- nizcount++;
- br = 1;
- temp = x[i];
- }
- }
- for(int i = 0; i < nizcount; i++){
- cout<<nizout[i]<<" ";
- }
- cout<<temp<<" "<<br;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement