1.输入一个字母,如果是小写,将其转换为大写;如果是大写,将其转换为小写。
2.显示以下图案:(用循环和数组编个具有普遍意义的)
                   A
                BBB
               CCCCC题目不难,大家别喷我,谢谢了,下次自己编

解决方案 »

  1.   

    public class Exchange {
    public static char exchange(char c){
    char res = c;

    if (c >= 'a' && c <= 'z')
    res -= 32;
    else if (c >= 'A' && c <='Z')
    res += 32;

    return res;
    }

    public static void main(String args[]){
    System.out.print(exchange('c') +" "+ exchange('C'));
    }
    }
      

  2.   

    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ss = s.toUpperCase();
    if(s.equals(ss)){
    System.out.println("大写!");
    System.out.println("转成:"+s.toLowerCase());
    }else{
    System.out.println("小写!");
    System.out.println("转成:"+s.toUpperCase());
    }

    }
      

  3.   

    public static void main(String[] args) {

    int count = 97;
    int y = 1;
    for(int i=3; i>0; i--){
    for(int j=0; j<i-1; j++){
    System.out.print(" ");
    }

    for(int k = 0;k < y; k++)
    System.out.print((char)count);
    System.out.println();
    y = y + 2;
    count++;

    }
    }
      

  4.   

    没怎么考虑,很简单的算法, 我你把count的值换下, 我的是小写的A..  
      

  5.   

    public class pic {
       private static int n=5;
       private static char[] ch={'A','B','C','D','E','F','G'};
       public static void main(String[] args) throws Exception{
          
          for(int i=1;i<=n;i++){
           for(int j=0;j<2*n-2*i;j++){
           System.out.print(" ");
           }
           for(int k=0;k<(2*i-1);k++){
            System.out.print(ch[i-1]);
           } 
           System.out.println();
          }
     
       
       }
    }
      

  6.   

    (1)import java.util.Scanner;public class SwitchCase {

    public static void main(String[] args) {

    Scanner scanner = new Scanner(System.in);
    System.out.println("请输入字符:");
    String input = scanner.next();
    if (input != null) {
    for (int i = 0; i < input.length(); i++)
    System.out.print(switchCase(input.charAt(i)));
    }
    }

    public static char switchCase(char c) {
    if (!Character.isLetter(c)) return c;
    if (Character.isUpperCase(c))
    return Character.toLowerCase(c);
    return Character.toUpperCase(c);
    }
    }
    (2)public class Triangle {

    public static void main(String[] args) {
    triangle('A', 'Z');
    }

    public static void triangle(char from, char to) {
    if (to < from) return;
    int height = to - from;
    for (int i = 0; i <= height; i++) {
    for (int j = 0; j < height-i; j++)
    System.out.print(' ');
    for (int j = 0; j < (i+1)*2-1; j++)
    System.out.print((char)(from + i));
    System.out.println();
    }
    }
    }
      

  7.   


     public static void main(String args[]){        
         char[] cha = {'A', 'B', 'C', 'D', 'E'};
         print(cha);
        }
        
        public static void print(char[] cha){
         int len = cha.length;
         for (int i = 0; i < len; i++) {
    for (int j = 1; j < len - i; j++) {
    System.out.print(" ");
    }
    for (int j = 0; j < 2 *i + 1; j++) {
    System.out.print(cha[i]);
    }
    System.out.println();
    }
        }
      

  8.   

    字符的大小写转换,A变成a,a变成A  /**
       * 字符的大小写转换,A变成a,a变成A.
       * 
       * @param c
       * @return
       */
      public static char toggle(char c) {
        return (char) ((c & 0x20) == 0 ? (c | 0x20) : (c & 0xDF));
      }
      

  9.   

    在JAVA的API有函数可以直接大写转小写,小写转大写,(如果我没有记错的话)建议查查API
      

  10.   

    第一题:public static void main(String[] args)

    Scanner sc = new Scanner(System.in); 
    String s = sc.next(); 
    System.out.println("小写:"+s.toLowerCase()); 
    System.out.println("大写:"+s.toUpperCase()); 

    第二题:public class Triangle {
        
        public static void main(String[] args) {
            triangle('A', 'C');
        }
        
        public static void triangle(char from, char to) {
            if (to < from) return;
            int height = to - from;
            for (int i = 0; i <= height; i++) {
                for (int j = 0; j < height-i; j++)
                    System.out.print(' ');
                for (int j = 0; j < (i+1)*2-1; j++)
                    System.out.print((char)(from + i));
                System.out.println();
            }
        }
    }
      

  11.   

    字符的大小写转换,A变成a,a变成A 
    Java code  /** 
      * 字符的大小写转换,A变成a,a变成A. 
      * 
      * @param c 
      * @return 
      */ 
      public static char toggle(char c) { 
        return (char) ((c & 0x20) == 0 ? (c | 0x20) : (c & 0xDF)); 
      } 
    这个比较爽啊。