-
2019-08-19 17:06:54
void ss (char *s,char t)
{
while (*s)
{
if(*s==t) *s=t-‘a’+’A’;
s++;
}
}
void main()
{
char str1[100]=“abcddfefdbd”,c=‘d’;
ss (str1,c); printf ("%s\n",str1);
}ABCDDEFEDBD
abcDDfefDbD
abcAAfefAbA
Abcddfefdbd解析:
函数ss的功能就是将字符串s中的所有字符为t的字符替换为大写字符。对
于主函数中的函数ss的调用,就是将字符串str1中的小些字符’d’替换成大写字符’D’。所以
正确答案是B。更多相关内容 -
Java 以下程序的输出结果为答
2021-03-09 22:33:356、以下程序的输出结果为答:publicclassTom{privatefloatweight;privatestaticStringname;publicvoidsetWeight(floatweight){this.weight=weight;}privatevoidout(){System.out.prin...6、以下程序的输出结果为答:...6、以下程序的输出结果为答:publicclassTom{privatefloatweight;privatestaticStringname;publicvoidsetWeight(floatweight){this.weight=weight;}privatevoidout(){System.out.prin...
6、以下程序的输出结果为答:
publicclass Tom {
privatefloatweight;
privatestatic String name;
publicvoid setWeight(float weight) {
this.weight = weight;
}
privatevoid out() {
System.out.println(name + "体重:" + weight + "斤");
}
publicstaticvoid main(String[] args) {
Tom.name = "汤姆猫";
Tom cat = new Tom();
cat.setWeight(20);
cat.out();
}
}
7、下列程序的运行结果是答:
publicclass MyClass {
inta[] = { 1, 2, 3, 4, 5 };
void out() {
for (int j = 0; j < a.length; j++)
System.out.print(a[j] + "");
}
publicstaticvoid main(String[] args) {
MyClass my = new MyClass();
my.out();
}
}
8.以下程序的输出结果为答:
classStringTest1
{
public static void main(String[] args)
{
String s1="hello";
String s2=new String("hello");
if(s1.equals(s2)){
System.out.println("相等");
}else{
System.out.println("不相等");
}
}
}
展开
-
以下程序的输出结果是:
2018-11-21 23:31:50以下程序的输出结果是: #include “stdio.h” main() {char *s,*s1=“here is”,*s2=“key”; s=s1; while (*s1!=’\0’) s1++; while (*s1++!=*s2++) s2=s; while (*s2!=’\0’) s2++; printf ("%d-%d=%d\n&...以下程序的输出结果是:
#include “stdio.h”
main()
{char *s,*s1=“here is”,*s2=“key”;
s=s1;
while (*s1!=’\0’) s1++;
while (*s1++!=*s2++) s2=s;
while (*s2!=’\0’) s2++;
printf ("%d-%d=%d\n",s2,s,s2-s);
}
之前一直不理解这个的结果是什么意思。。
#include "stdio.h" main() {char *s,*s1="here is",*s2="key"; s=s1; //从这里开始,print的s=s1=19748668,即字符串存储起始位置 while (*s1!='\0') s1++;//s1向后走,直到字符串的末尾\0,此时printf的s1=19748675 while (*s1++!=*s2++) s2=s; //这行功能:比较s1与s2,s1的“h”(位置为s+1=19748669)与s2的“k”不同,则s2=s //这行执行后:s1=19748922,s2=19748669 while (*s2!='\0') s2++; //这行让s2查找至末尾\0: s2=19748675(*s2="here is") printf ("s=%d\n",s); printf ("s1=%d\n",s1); printf ("s2=%d\n",s2); printf ("%d-%d=%d\n",s2,s,s2-s);//s2-s即“here is”的长度为7 }
每次执行程序,存储位置都不一定相同,故s,s1,s2的值每次都会有所不同,但是存储的相对位置是不会改变的,s2-s即“here is”的长度,为7。
-
以下程序输出结果是____。
2017-08-01 16:27:24以下程序输出结果是__。class A { public: virtual void func(int val = 1) { std::cout<<"A->";} virtual void test() { func();} }; class B : public A { public: void func(int val=0以下程序输出结果是__。
class A { public: virtual void func(int val = 1) { std::cout<<"A->"<<val <<std::endl;} virtual void test() { func();} }; class B : public A { public: void func(int val=0) {std::cout<<"B->"<<val <<std::endl;} }; int main(int argc ,char* argv[]) { B*p = new B; p->test(); return 0; }
正确答案: B
A、A->0
B、B->1
C、A->1
D、B->0
E、编译出错
F、以上都不对正确答案:B
记住:virtual 函数是动态绑定,而缺省参数值却是静态绑定。 意思是你可能会 在“调用一个定义于派生类内的virtual函数”的同时,却使用基类为它所指定的缺省参数值。
结论:绝不重新定义继承而来的缺省参数值!(可参考《Effective C++》条款37)
对于本例:B*p = newB;
p->test();p->test()执行过程理解:
(1) 由于B类中没有覆盖(重写)基类中的虚函数test(),因此会调用基类A中的test();
(2) A中test()函数中继续调用虚函数 fun(),因为虚函数执行动态绑定,p此时的动态类型(即目前所指对象的类型)为B*,因此此时调用虚函数fun()时,执行的是B类中的fun();所以先输出“B->”;
(3) 缺省参数值是静态绑定,即此时val的值使用的是基类A中的缺省参数值,其值在编译阶段已经绑定,值为1,所以输出“1”;
最终输出“B->1”。所以大家还是记住上述结论:绝不重新定义继承而来的缺省参数值! -
下面程序的输出结果是( )
2020-09-11 18:15:36int main() { int i, n = 0; float x = 1, y1 = 2.1 / 1.9, y2 = 1.9 / 2.1; for ( i = 1; i < 22; i++) x = x * y1; while ( x != 1.0 ) { x = x * y2; n++; } printf( "%d\n", n ); return 0; } 答案:... -
执行下面程序中的输出语句后,输出结果是______. #include void main() {int a; printf("%d\n",(a=3*5,a*4,...
2021-05-21 13:00:16A、运行程序段后输出0B、运行程序段后输出1C、程序段中的控制表达式是非法的D、程序段循环无数次[单选题]下面程序段的输出结果是________.x=3;do { y=x--;if (!y) {printf("*");continue;}printf("... -
写出下面程序输出结果
2020-09-06 20:46:21int main(){ int x=1, y=0 ,a=0, b=0; switch(x) { case 1: //此时X=1,进入case1; switch(y) { case 0:a++;//此时y=0,进入case0;,a++后break跳出switch(y) case 1:b++; } case 2: a++;//因为 switch(x) 的 case 1... -
以下程序运行后的输出结果是()?(会跳出循环嗷)
2019-08-20 16:36:04main() { int p[7]={11,13,14,15,16,17,18}; int i=0,j=0; while(i<7 && p[i]%2==1) j+=p[i++]; printf("%d\n",j); } 正确答案: B 你的答案: B (正确) 23 24 25 26 i等于0时,p[0]为奇数,进入while循环,... -
以下C#程序的输出结果是( )。
2016-02-24 10:36:00以下程序的输出结果是( )。 using System; namespace HoverTreeTikuConsole { class Program { static void Main(string[] args) { MyStruct s1 = new MyStruct(1, 2); s1.x = 2; s1.Sum(); ... -
1.执行如下程序,输出结果是( )
2020-07-21 22:02:05} } } class ThreadTest { public static void main(String args[]) { Test mv = new Test(); Thread t1 = new ThreadExample(mv); Thread t2 = new ThreadExample(mv); Thread t3 = new ThreadExample(mv); t1.... -
执行如下程序, 输出结果是()
2019-07-30 11:29:56class Test { private int data; int result = 0; public void m() { result += 2; data += 2;... System.out.print(result + " " + data);... print方法, 不会自动换行, 所以输出结果是2 24 46 6 -
下列程序的输出结果为() public class Test { public static void main(String[] args) { int i=0;...
2021-03-09 22:33:31【其它】请提交实验五压缩包【判断题】线程t1中执行t2.sleep(5000)语句,则线程t2休眠5s【判断题】Java源程序中的文件名一定要和文件中某个类的名称一致() (5.0分)【单选题】下列程序的输出结果为() public class ... -
面试题 以下程序的输出结果是什么
2015-02-26 08:43:45import java.math.BigInteger; public class Test { ...public static void main(String[] args) throws NumberFormatException{ BigInteger one = new BigInteger("1"); BigInteger two = new BigInteger("2") -
以下程序的输出结果是( )。 #include int f(int a)
2021-04-23 10:55:08以下程序的输出结果是( )。 #include int f(int a) { int b=0; static int c=3; a=c++,b++; return a; } void main() { int a,i,t; a=3; ... -
以下程序段的输出结果为()。
2020-09-13 19:46:25for(i=4;i>1;i–) for(j=1;j<i;j++) putchar(’#’); 答案:###### 解析:内部循环完了之后再进行外部循环,第二次外部循环的时候...putchar:c语言函数之一,作用是向终端输出一个字符,这里一共循环输出6次 ... -
以下程序的输出结果是( ) C语言的
2016-01-13 12:43:55以下程序的输出结果是( ) # include<stdio.h> subl(char a,char b) {char c;c=a;a=b;b=c;} sub2(char *a,char b){ char c;c=*a;*a=b;b=c;} sub3(char *a,char *b) { char c;c=*a;*a=*b... -
给定以下JAVA代码,这段代码编译运行后输出的结果是( )
2021-03-15 22:39:42给定以下JAVA代码,这段代码编译运行后输出的结果是( )publicclassTest{publicstaticintaMethod(inti)throwsException{try{returni/10;}catch(Exceptionex){thrownewException("exceptioninaaMothod");}finally{... -
下列程序执行后输出的结果是
2020-09-13 20:08:14#include<iostream> using namespace std; int f(int a) { int b = 0; static int c = 3;...int main() { int a = 2, i, k; for (i = 0; i < 2; i++) k = f(a++); printf(" % d\n", k); ret -
Java基础题11: (单选题)编译运行以下程序后,关于输出结果的说明正确的是( ) publicclass Conditional{
2020-08-15 23:57:42 -
Java基础题10:(单选题)以下代码的输出结果是() public class Test { public static void main(String[] ...
2020-08-15 23:55:19 -
编写一个C程序,运行时输出以下图形:
2021-04-26 10:42:44编写一个C程序,运行时输出以下图形: **** **** **** **** 代码示例: #include <stdio.h> int main() { for (int i = 0; i < 4; i++) { for (int j = 0; j < i; j++) { printf("%s", " ... -
下面程序的运行结果是: main() { int x,i,j; for(i=1;i;i++) { x=i;
2020-11-20 17:02:29下面程序的运行结果是: main() { int x,i,j; for(i=1;i<=100;i++) { x=i; if(++x%20) if(++x%30) if(++x%7==0) printf("%d ",x); } } A)39 81 B)42 84 C)26 68 D) 28 70 nt x,i; //定义两个整型变量dao for(i=1;i... -
第十四题: 以下代码的输出结果是?
2019-11-14 15:54:27以下代码的输出结果是? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 public class B { public static B t1 = new B(); ..... -
以下程序运行后的输出结果是:int fun(int n){static int s=1;s*=n;return s;main(){int i,s=0;for(i=1...
2021-06-06 18:56:41再来看这行代码 因为s += fun(i),右边的fun(i)经过第一次计算完后,返回了1 所以main函数中,s += fun(i) => s = 0+1=1,s=1 第二次循环,s=1,i=2 进入fun函数计算,n=2,s=1(用上一次计算后的值) s*=n => s=sn=12... -
面试题:以下程序的输出结果是
2015-03-02 11:15:55public static void main(String[] args) { // TODO Auto-generated method stub A a = new B(); a = new A(); } } ———————————————————————— A B A -
用C语言如何编写程序输出以下图形
2021-05-19 20:08:28用C语言如何编写程序输出以下图形关注:169答案:3mip版解决时间 2021-01-18 16:55提问者傃顏莄蒾亾2021-01-17 19:07* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *最佳答案二级知识专家妳... -
下列程序运行时输入: abcd<CR> (<CR> 代表回车符 ) ,输出结果是 ( ) 。 #include <stdio.h> #include ...
2021-02-04 15:32:21【简答题】对话4【单选题】下列程序运行时输入: abcd ( 代表回车符 ) ,输出结果是 ( ) 。 #include #include int main() { char ss[10]="12345"; gets(ss); strcat(ss,"6789"); printf("%s\n",ss); return 0; }... -
46. 执行以下程序的结果是什么?(答案详析)
2020-10-12 08:55:451. 程序代码 public class Test { private String name = "abc"; public static void main(String[] args) { Test test = new Test(); Test testB = new Test(); String result = test.equals(testB) + ","; ... -
以下程序的运行结果是( ) main( ) { int a=-5,b=1,c=1; int x=0,y=2,z=0; if(c>0) x=x+y; if(a) { if(b>0) ...
2021-03-12 20:33:49【填空题】有以下程序段: s=1.0; for(k=1; k<=n; k++) s=s+1.0/(k*(k+1)); printf("%f\\n",s); 请填空,使下面的程序段的功能完全与之等同。 s=0.0; ____; k=0; do { s=s+d; ____; d=1.0/(k*(k+1)); } while(____)...