Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3. Online C++ Compiler.
  4. Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10.  
  11. using namespace std;
  12.  
  13. int a, nizin[100], nizout[1000], br = 1, nizcount=0;
  14. string x;
  15.  
  16. int main()
  17. {
  18. cin>>a;
  19. for(int i = 0; i < a; i++){
  20. cin>>nizin[i];
  21. x+=to_string(nizin[i]);
  22. }
  23. char temp = x[0];
  24. for(int i = 1; i < x.length(); i++){
  25. if(x[i] == temp){
  26. br++;
  27. } else {
  28. nizout[nizcount] = temp-48;
  29. nizcount++;
  30. nizout[nizcount] = br;
  31. nizcount++;
  32. br = 1;
  33. temp = x[i];
  34. }
  35. }
  36. for(int i = 0; i < nizcount; i++){
  37. cout<<nizout[i]<<" ";
  38. }
  39. cout<<temp<<" "<<br;
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement