1 solutions

  • 0
    @ 2025-11-5 16:55:36

    C :

    #include<stdio.h>
    #include<string.h>
    int main()
    {
    	char str[80];
    	int len,i,a=0,b=0;
    	gets(str);
    	len=strlen(str);
    	for(i=0;i<len;i++)
    	{
    		if (('A'<=str[i])&&(str[i]<='Z'))
    		{
    			str[i]=str[i]+32,a++;
    		}
    		else if (('a'<=str[i])&(str[i]<='z'))
    		{
    			str[i]=str[i]-32,b++;
    		}
    	}
    	puts(str);
    	printf("%d %d",b,a);
    	return 0;
    }
    

    C++ :

    #include <iostream>
    #include <string>
    using namespace std;
    int main()
    {
    	int big = 0, small = 0;
    	string s;
    	cin >> s;
    	for (int i = 0; i < s.size(); i++)
    	{
    		if (s[i] >= 'A' && s[i] <= 'Z')
    		{
    			small++;
    			s[i] += 32;
    		}
    		else
    		{
    			big++;
    			s[i] -= 32;
    		}
    	}
    	cout << s << endl;
    	cout << big << ' ' << small << endl;
    	return 0;
    }
    
    
    • 1

    Information

    ID
    18080
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By