3 solutions

  • 6
    @ 2024-7-24 14:35:40
    #include<bits/stdc++.h>
    using namespace std;
    const int N=510;
    char s[N];
    int main()
    {
    	cin.getline(s,N);
    	int n=strlen(s);
    	for(int i=0;i<n;i++)
    	{
    		if(s[i]==' ')
    		{
    			cout<<" ";
    			continue;
    		}
    		int j=i+1;
    		while(j<n&&s[j]!=' ') j++;
    		j--;
    		for(int k=j;k>=i;k--)
    		{
    			cout<<s[k];
    		}
    		i=j;
    	}
    	return 0;
    }
    
    • 1
      @ 2025-7-15 14:09:05
      #include<bits/stdc++.h>
      using namespace std;
      const int N=510;
      char s[N];
      int main()
      {
      	cin.getline(s,N);
      	int n=strlen(s);
      	for(int i=0;i<n;i++)
      	{
      		if(s[i]==' ')
      		{
      			cout<<" ";
      			continue;
      		}
      		int j=i+1;
      		while(j<n&&s[j]!=' ') j++;
      		j--;
      		for(int k=j;k>=i;k--)
      		{
      			cout<<s[k];
      		}
      		i=j;
      	}
      	return 0;
      }
      
      
      • -1
        @ 2025-7-15 14:09:36
        `
        
        
        • 1

        Information

        ID
        922
        Time
        1000ms
        Memory
        256MiB
        Difficulty
        1
        Tags
        (None)
        # Submissions
        79
        Accepted
        28
        Uploaded By