下面的程序功能是实现字符串大小写的转换并倒序输出。public static void Main(string[] args){ string str = "HelloWorld"; ______ sb=new StringBuilder(); for (int i = 0; i < str.______ ; i++) { if (str[i] >= 'a' && str[i] <= 'z') { sb.Append( str[i].ToString().ToUpper()); } else { sb.Append( str[i].ToString().______ ()); } } Console.WriteLine(sb.ToString()); Console.ReadKey();}[/i][/i][/i][/i]
举一反三
- 5、下列程序的运行结果是()。public static void main( String[] args ){StringBuffer sb = new StringBuffer();sb.append("qq").append("ww");show( sb, "ss" );System.out.println( sb.length() );}public void show( StringBuffer sb, String str ){sb.append( str );} A: 4 B: 2 C: 6 D: 0
- 下面程序的功能是从输入的十个字符串中找出最长的那个串。请填空。#include “stdio.h”#include “string.h”#define N 10main(){ char str[N][81],*sp;int i;for(i=0;i<;N;i++) gets(str[i]);sp=( ① );for(i=1;i<;N;i++) if(strlen(sp)<;strlen(str[i])) str[i];printf(“sp=%d,%s\n”,strlen(sp),sp);}[/i][/i][/i] A: str[i] B: &str[i][0] C: str[0] D: str[N]
- public class Example { String str = new String("Java"); StringBuffer sb = new StringBuffer("C#"); public void strcat(String str, StringBuffer sb) { str = str + " study"; sb = sb.append(" exam"); } public static void main(String args[]) { Example ex = new Example(); ex.strcat(ex.str, ex.sb); System.out.println(ex.str); System.out.println(ex.sb); }}程序的输出结果是:______
- 分析下程序,写出输出结果。 #include [stdio.h] #include [string.h] void main( ) { char str[]="123456"; int i,x; char t; x=strlen(str)-1; for (i=0;i<=x/2;i++) { t=str[i]; str[i]=str[x-i]; str[x-i]=t; } puts(str); }[/i][/i]
- String str="i"与 String str=new String("i")一样吗?