Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdio>
- using namespace std;
- int main(){
- int t; cin >> t;
- while(t--){
- int n; cin >> n;
- char str[n+1];
- cin.ignore();
- gets(str);
- int i, j = 0, flag1 = 0, flag2 = 0;
- for(i = 0; i < n; i++){
- if(i == 0 && str[i] == ' ') {
- flag1 = 1;
- continue;
- }
- if(i == n-1 && str[i] == ' ') {
- flag2 = 1;
- continue;
- }
- if(str[i] == ' ' && i != 0) str[j++] = '_';
- else str[j++] = tolower(str[i]);
- }
- if(flag1) n--;
- if(flag2) n--;
- for(i = 0; i < n; i++){
- cout << str[i];
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement