1 solutions

  • 0
    @ 2024-12-20 22:52:18

    C :

    #include<stdio.h>
    #include<string.h>
    #include<ctype.h>
    
    int main()
    {
    	int t,i;
    	char a[51];
    	scanf("%d%*c",&t);
    	while(t--)
    	{
    		gets(a);
    		for(i=0;i<strlen(a);i++)
    		{
    			if(a[i]=='A'||a[i]=='a'||a[i]=='E'||a[i]=='e'||a[i]=='I'||a[i]=='i'||a[i]=='O'||a[i]=='o'||a[i]=='U'||a[i]=='u')
    				a[i]=toupper(a[i]);
    			else
    				a[i]=tolower(a[i]);
    		}
    		puts(a);
    	}
    	return 0;
    }
    

    C++ :

    #include<stdio.h>
    #include<string.h>
    #include<ctype.h>
    
    int main()
    {
    	int t,i;
    	char a[51];
    	scanf("%d%*c",&t);
    	while(t--)
    	{
    		gets(a);
    		for(i=0;i<strlen(a);i++)
    		{
    			if(a[i]=='A'||a[i]=='a'||a[i]=='E'||a[i]=='e'||a[i]=='I'||a[i]=='i'||a[i]=='O'||a[i]=='o'||a[i]=='U'||a[i]=='u')
    				a[i]=toupper(a[i]);
    			else
    				a[i]=tolower(a[i]);
    		}
    		puts(a);
    	}
    	return 0;
    }
    

    Pascal :

    var n,i,j:integer;
        a:string;
    begin
      readln(n);
      for i:=1 to n do begin
        readln(a);
        for j:=1 to length(a) do 
          if ord(a[j])<=90 then a[j]:=chr(ord(a[j])+32);
        for j:=1 to length(a) do begin
          if (a[j]='a') or (a[j]='e') or (a[j]='i') or (a[j]='o') or (a[j]='u') then write(upcase(a[j])) else write(a[j]);
        end;
        writeln;
      end;
    end.
                  
    

    Java :

    import java.util.Scanner;
    
    public class Main {
    	
    	public static void main(String[] args){
    		Scanner in = new Scanner(System.in);
    		int t = in.nextInt();
    		while(t-->0){
    			String s = in.next();
    			StringBuffer sb = new StringBuffer();
    			for(int i=0;i<s.length();i++){
    				char c = s.charAt(i);
    				if(c>'Z'){
    					if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')sb.append((char)(c-'a'+'A'));
    					else sb.append(c);
    				}else {
    					if(c=='A'||c=='E'||c=='I'||c=='O'||c=='U')sb.append(c);
    					else sb.append((char)(c-'A'+'a'));
    				}
    			}
    			System.out.println(sb);
    		}
    	}
    }
    
    

    Python :

    import sys
    
    l = 1
    Z = ['a','e','i','o','u','A','E','I','O','U']
    for line in sys.stdin:
        data = list(line.split()[0])
        if l!=1:
           r = map(lambda x:x.upper() if x in Z else x.lower(),data)
           print ''.join([i for i in r])
        l += 1
    

    C# :

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                string str;
                int t=Convert.ToInt32(Console.ReadLine());
                while (t>0) 
                {
                    str = Console.ReadLine();
                    string ans = string.Empty;
                    str=str.ToLower();
                    for (int i = 0; i < str.Length; i++)
                    {
                        if (str[i].Equals('a') || str[i].Equals('i') || str[i].Equals('e')
                            || str[i].Equals('u') || str[i].Equals('o'))
                        {
                            ans += str[i].ToString().ToUpper();
                        }
                        else ans += str[i].ToString();
                    }
                        Console.WriteLine(ans);
                    t--;
                }
            }
        }
    }
    
    
    
    
    
    
    • 1

    Information

    ID
    785
    Time
    1000ms
    Memory
    32MiB
    Difficulty
    9
    Tags
    # Submissions
    17
    Accepted
    2
    Uploaded By