Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- //#include <stdlib.h>
- //#include <string.h>
- int main()
- {
- int m;
- int zero=0;
- int one=0;
- int i=0;
- char c[5];
- scanf(" %d ", &m);
- scanf(" %[^\n]", c);
- for(i=0; i<(sizeof(c)/sizeof(char)); i++){
- if(c[i]=='\0'){
- break;
- }
- if(c[i]=='z')
- zero+=1;
- else if(c[i]=='n')
- one+=1;
- }
- int sizeOfArray = zero + one;
- char finalArray[sizeOfArray+1];
- for(i=0; i<one; i++){
- finalArray[i] = '1';
- }
- for(i=one; i<zero+one; i++){
- finalArray[i] = '0';
- }
- for(i=0; i<(sizeof(finalArray)/sizeof(char)); i++){
- if(finalArray[i]=='\0'){
- break;
- }
- if(finalArray[i+1]=='\0'){
- printf("%c", finalArray[i]);
- }
- else
- printf("%c ", finalArray[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement