网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
下列程序的输出结果是: def f1 (my_dict): temp = 0 for value in my_dict.values(): temp = temp + value return temp a_dict={'bill':1,'rich':2,'fred':10,'walter':20} print f1(a_dict)
参考答案和解析
D
更多 “下列程序的输出结果是: def f1 (my_dict): temp = 0 for value in my_dict.values(): temp = temp + value return temp a_dict={'bill':1,'rich':2,'fred':10,'walter':20} print f1(a_dict)” 相关考题
考题
( 12 ) 有以下程序#include stdio.h#include string.hvoid fun ( char *str ){ char temp;int n,i;n=strlen ( str ) ;temp=str[n-1];for ( i=n-1;i0;i-- ) str[i]=str[i-1];str[0]=temp;}main (){ char s[50];scanf ( " %s " ,s ) ; fun ( s ) ; printf ( " %s\n " ,s ) ;}程序运行后输入: abcdef 回车 ,则输出结果是 【 12 】 。
考题
阅读以下程序说明和C++程序,将程序段中(1)~(5)空缺处的语句填写完整。【说明】以下【C++程序】实现一个简单的小型复数类MiniComplex,该复数类能进行输入、输出、复数的加法、减法、乘法和除法运算,还可以进行复数的相等比较。【C++程序】ifndef H_MiniComplexdefine H_MiniComplexinclude <iostream>using namespace std;class MiniComplex{public: //重载流插入和提取运算符(1) ostreamoperator<<(ostream osObject,const MiniComplexcomplex){osObject<<"("<<complex.realPart<<"+"<<complex.imagPart<<"i"<<")";return osObject;}(2) istreamoperator>>(istreamisObject, MiniComplexcomplex){char ch;isObject >>complex.realPart>>ch>>complex.imagPart>>ch;return isObject;}MiniComplex(double real=0,double imag=0); //构造函数MiniComplex operator+(const MiniComplexotherComplex)const; //重载运算符+MiniComplex operator-(const MiniComplexotherComplex)const; //重载运算符-MiniComplex operator*(const MiniComplexotherComplex)const; //重载运算符*MiniComplex operator/(const MiniComplexotherComplex)const; //重载运算符/bool perator==(const MiniComplexotherComplex)const; //重载运算符==private :double (3);double imagPart;};end ifinclude "MiniComplex.h"bool MiniComplex::operator==(const MiniComplexotherComplex)const{return(realPart==otherComplex.realPartimagPart==ortherComplex.imagPart);}MiniComplex::MiniComplex(double real,double imag){realPart== real; imagPart==imagPart;}MiniComplex MiniComplex::operator+(const MiniComplexotherComplex)const{MiniComplex temp;temp.realPart = realPart+ortherComplex. realPart;temp.imagPart = imagPart +ortherComplex. imagPart;return temp;}(4){ MiniComplex temp;temp.realPart= realPart-ortherComplex. realPart;temp.imagPart = imagPart-ortherComplex. imagPart;return temp;}MiniComplex MiniComplex::operator*(const MiniComplexotherComplex)const{MiniComplex temp;temp.realPart = (realPart*ortherComplex. realPart)-(imagPart *ortherComplex.imagPart);temp.imagPart = (realPart*ortherComplex. imagPart)+(imagPart *ortherComplex.realPart);return temp;}MiniComplex MiniComplex::operator/(const MiniComplexotherComplex)const{MiniComplex temp;float tt;tt=1/(ortherComplex.realPart*ortherComplex.realPart+ortherComplex.imagPart *ortherComplex. imagPart);temp.realPart=((realPart*ortherComplex, realPart)+(imagPart *ortherComplex. imagPart))*tt;temp.imagPart =((imagPart *ortherComplex. realPart)-(realPart*ortherComplex. imagPart))*tt;return temp;}include <iostream>include <MiniComplex.h>using namespace std;int main(){MiniComplex numl(23, 34),num2(56, 35);cout<<"Initial Value of num1="<<num1<<"\n Initial Value of num2="<<num2<<end1;cout<<num1<<"+"<<num2<<"="<<num1+num2<<end1; //使用重载的加号运算符cout<<num1<<"-"<<num2<<"="<<num
考题
以下函数模板min的功能是返回数组a中最小元素的值。请将横线处缺失部分补充完整。template<typename T>T min(T a[],int n){T temp=a[0];for(int i=1,i<n;i++)if(a[i]<temp)______;return temp;}
考题
有如下SQL语句: SELECT MAX(人数)FROM 班级 INTO ARRAY temp 执行该语句后( )。A.temp[0]的内容为44B.temp[0]的内容为50C.temp[1]的内容为44D.temp[1]的内容为50
考题
阅读程序:Function fac(ByVal n As Integer)As IntegerDim temp As Integertemp=1For i%=1 To ntemp=temp*i%Next i%fac=tempEnd FunctionPrivate Sub Form_Click()Dim nsum As Integernsum=1For i%=2 To 4nsum=nsum+fac(i%)Next i%print nsumEnd Sub程序运行后,单击窗体,输出结果是A.35B.31C.33D.37
考题
以下程序执行后输出的结果是【】。 include include using namespace std; int
以下程序执行后输出的结果是【 】。include<iostream>include<fstream>using namespace std;int main(){ofstream ofile("D:\\temp.txt");if(!ofile){cout<<"temp.txt cannot open"<<endl;return 0;}ofile<<"This is a book" <<" " <<54321<<endl;ofile.close();ifstream ifile("D:\\temp.txt");if(!ifile){cout<<"temp.txt cannot open" <<endl;return 0;}charstr[40];ifile >> str;ifile.close();cout<<Str<<endl;return 1;}
考题
有以下程序:class Date{public:Date(int y,int m,int d);{year=y;month=mday=d;}Date(int y=2000){year=y;month=10;day=1;}Date(Date d){year=d.year;month=d.month;day=d.day;}void print( ){cout<<year<<"."<<month<<"."<<day<<endl;}private:int year,month,day;};Date fun(Date d){Date temp;temp=d;return temp;}int main( ){Date datel(2000,1,1),date2(0,0,0);Date date3(datel);date2=fun(date3);return 0;}程序执行时,Date类的拷贝构造函数被调用的次数是A.2B.3C.4D.5
考题
向顺序文件Temp.txt中写入1,2,3这3个数。在程序中加入以下语句的哪一项可以使程序功能完整。Private Sub Command1_Click()Open "c:\Temp.txt",Output As#1For i=0 To 3NextClose #1End SubA.Print #1,Temp.txtB.Get #1,iC.Print #1,iD.Unit #1,i
考题
下列程序的招待结果是【 】。 include float temp;float fn2(float r){ temp=r*
下列程序的招待结果是【 】。include <iostream. h>float temp;float fn2(float r){temp=r* r* 3.14;return temp;}void main( ){float a=fn2(5.0);float b=fn2(5.0)b=20;cout<<temp<<end1;}
考题
欲执行程序temp.prg,应该执行的命令是( )。A.DO PRG temp.prgB.DO temp.prgC.DO CMD temp.prgD.DO FORM. temp.prg
考题
下列程序的执行结果是______。 include float temp; floatfn2(float r) { temp=
下列程序的执行结果是______。include<iostream.h>float temp;floatfn2(float r){temp=r*r*3.14;return temp;}void main( ){float a=fn2(5.0);floatb=fn2(5.0);b=20;cout<<temp<<endl;}
考题
下面程序输出的结果是( )。 include using namespace std; void swap(int
下面程序输出的结果是( )。 #include <iostream> using namespace std; void swap(int a,int b){ int temp; temp=a; a=b; b=temp; } void main(){ int x=2; int y=3; swap(x,y); cout<<x<<y; }A.23B.32C.abD.ba
考题
下面程序输出的结果为()。includevoid fun(int a,int b){int temp;temp=a;a=b;b=tem
下面程序输出的结果为( )。 #include<iostream.h> void fun(int a,int b) { int temp; temp=a; a=b; b=temp; } void main() { int m,n; m=1; n=2; fun(m,n); cout<<m<<""<<n<<end1; }A.12B.21C.22D.程序有错误
考题
阅读以下说明及C++程序代码,将应填入(n)处的语句写在对应栏内。【说明】本程序的功能是生成螺旋方阵,用户可以输入该方阵的行列数,然后就生成对应的螺旋方阵。例如:当n=5时,对应的螺旋方阵如下:1 16 15 14 132 17 24 23 123 18 25 22 114 19 20 21 105 6 7 8 9【C++代码】include"stdio.h"include"iostream,h"int array[11][11];int temp;int ROW;void godown(int m,int a){for(temp=1; temp<=ROW;temp++)if(array[temp][a]==0)array[temp][a]=(1);a++;}void goright(int m,int b){for(temp=1;temp<=ROW;temp++)if(array[b][temp]==0)array[b][temp]=m++;b--;}void goup(int m.int c){for(temp=ROW;temp>0;temp-)if(array[temp][c]==0)array[temp][c]=m++;c--;}void goleft(int m,int d){for(temp=ROW;temp>0;temp--)if(array[d][temp]==0)array[d][temp]=m++;(2);}void main(){int a,b,c,d,max,m;cin>>ROW;cout>>end1;for(a=1;a<=ROW;a++)for(b=1;b<=ROW;b++)(3);m=1;a=d=1;b=c=ROW;max=(4);whiie(m<=max){godown(m,a);(5) (m,b);goup(m,c);goleft(m,d):}for(a=1;a<=ROW;a++){for(b=1;b<=ROW;b++)printf("%3d ",array[a][b]);cout<<end1;}}
考题
向顺序文件Temp.txt中写入1,2,3这3个数。在程序中加入以下语句的那项可以使程序功能完整。Private Sub Command1_ClickOpen"c:\Temp.txt",Output As #1For i=0 To 3NextClose #1End SubA.Print #1,Temp.txtB.Get #1,iC.Print #1,iD.Unit #1,i
考题
阅读程序: Function fac(ByVal As Integer)As Integer Dim temp As Integer temp=1 For i%=1 To n temp=temp*i% Next i% fac=temp End Function Private Sub Form. Click( ) Dim nsum As Integer nsum=1 For i%=2 T0 4 nsum=nsum+fac(i%) Next i% Print nsum End Sub 程序运行后,单击窗体,输出结果是( )。A.35B.31C.33D.37
考题
下列程序段的输出结果是 CLEAR STORE 10 TO A STORE 20 TO B SET UDFPARMS TO REFERENCE DO SWAP WITH A,(B) ?A,B PROCEDURE SWAP PARAMETERS Xl,X2 TEMP=X1 X1=X2 X2=TEMP ENDPROCA.10 20B.20 20C.20 10D.10 10
考题
阅读以下技术说明和C代码,将C程序中(1)~(5)空缺处的内容填写完整。[说明]某种传感器的输出值Ratio依赖于环境温度temp(-40℃≤temp≤50℃)。对一组环境温度值(ITEMS个),已经测量得到了相应的Ratio值(如表4-10表格所示)。表4-10粗略地描述了曲线Ratio(temp)。校正系数K是Ratio的倒数,因此也依赖于环境温度temp。在数据处理中,需要用更多的列表值细致地描述曲线K(temp),如表4-11所示。在表4-11中,各温度值所对应的K值是对表4-10进行线性插值再求倒数得到的,具体的计算方法如下。1) 根据temp值,在表4-10中用二分法查找;2) 若找到相应的温度值,则按相应的Ratio值求倒数得到K值;3) 若没找到相应的温度值,则可确定temp所在的温度区间[Tp1,Tp2],同时获得了相应的Ratio1和 Ratio2,再按如下公式计算K值:在程序中,当temp高于50℃或低于-40℃C时,设定K=0。[C程序]includetypedef struct {int Temp; /* 环境温度 */double Ratio; /* 传感器的输出值 */}CURVE;define ITEMS 7double GetK(int Temp,CURVE *p,int n){ /* 用二分法在n个元素的有序表p中查找与Temp对应的传感器输出值 */int low, high, m;double Step;low = 0;high = n-1;if ((Temp<p->Temp) || (Temp>(p+high)->Temp))return 0.0; /* 超出温度范围时返回 0.0 */while (low<=high){ m=(1);if (Temp==(p+m)->Temp)return (2);if (Temp<(p+m) >Temp)high=m-1;elselow=(3);}p+=high;Step=( (4) )/((p+1)->Temp-p->Temp);return 1.0/ (p->Ratio + Step*( (5) ) ;}void main(){ int Degree;double k;CURVE Curve [ITEMS]={{-40,0.2},{-20,0.60.},{-10,0.8},{0,1.0},{10,1.17},{30,1.50},{50,1.8}};printf ("环境温度 校正系数\n");for (Degree=-40;Degree<=50;Degree++){ k=GetK ( Degree, Curve, ITEMS);printf("%3d %4.2f\n",Degree,k);}}
考题
下列程序段的输出结果是 ______。 CLEAR STORE 10TOA STORE 20TOB SET UDFPARMS TO REFERENCE DO SWAP WITH A,B) ?A,B PROCEDURE SWAP PARAMETERS X1,X2 TEMP=X1 X1=X2 X2=TEMP ENDPROCA.10 20B.20 20C.20 10D.10 10
考题
阅读以下说明和C程序,将应填入(n)处。[说明]某种传感器的输出值Ratio依赖于环境温度temp(-40℃≤temp≤50℃)。对一组环境温度值(ITEMS个),人们已经测量得到了相应的Ratio值(见表1)。该表粗略地描述了曲线Ratio(temp)。校正系数K是Ratio的倒数,因此也依赖于环境温度temp。在数据处理中,人们需要用更多的列表值细致地描述曲线K(temp),如表2所示。在表2中,各温度值所对应的K值是对表1进行线性插值再求倒数得到的,具体的计算方法如下:1.根据temp值,在表1中用二分法查找;2.若找到相应的温度值,则按相应的Ratio值求倒数得到K值:3.若没找到相应的温度值,则可确定temp所在的温度区间[Tp1, Tp2],同时获得了相应的Ratio1和Ratio2,再按如下公式计算K值:Step=(Ratlo1-Ratio2)/(Tp1-Tp2)K=1.0/(Ratio1+Step*(temp-Tp1))在程序中,当temp高于50℃或低于-40℃时,设定K=0。[程序]include <stdio.h>typedef struct {int Temp; /*环境温度*/double Ratio; /*传感器的输出值*/}CURVE;define ITEMS 7double GetK(int, CURVE*, int);void main(){int Degree;double k;CURVE Curve[ITEMS]={ {-40,0.2},{-20,0.60},{-10,0.8},{0,1,0},{10,1.17},{30,1.50}, {50,1.8} };printf("环境温度 校正系数\n");for( Degree= 40; Degree<=50; Degree++){k=GetK(Degree, Curve, ITEMS);printf(" %3d %4.2f\n",Degree,k);}}double GetK(int Temp, CURVE *p, int n){/*用二分法在n个元素的有序表p中查找与Temp对应的传感器输出值*/int low,high,m; double Step;low=0; high=n-1;if((Temp<p->Temp) ||( Temp>(p+high)->Temp))return 0.0; /*超出温度范围时返回0.0*/while (low<=high){m=(1) ;if(Temp==(p+m)->Temp)return (2);if (Temp<(p+m)->Temp)high=m-1;else low=(3);}p+= high;Step=((4))/((p+1)->Temp-p->Temp);return 1.0/(p->Ratio +Step *((5)));}
考题
有下列SQL语句:SELECT MAX(人数) FROM 班级 INTO ARRAY temp执行该语句后( )。A.temp[0]的内容为44B.temp[0]的内容为50C.temp[1]的内容为44D.temp[1]的内容为50
考题
下列代码执行之后,输出的结果为______。 public class ex38 { public static void main(String[] args) { int x=12; int m=11; int y=13; int temp=x>y?x:y; temp=temp>m?temp:m; System.out.println (temp); } }A.1B.12C.13D.11
考题
下面程序的运行结果为( )。def swap(list): temp=list[0] list[0]=list[1] list[1]=templist=[1,2]swap(list)print(list)
A.[1,2]B.[2,1]C.[2,2]D.[1,1]
考题
阅读程序:Function fac(ByVal As Integer)As IntegerDim temp As Integertemp=1For i%=1 To ntemp=temp*i%Next i%fac=tempEnd FunctionPrivate Sub Form. Click( )Dim nsum As Integernsum=1For i%=2 T0 4nsum=nsum+fac(i%)Next i%Print nsumEnd Sub程序运行后,单击窗体,输出结果是( )。A.35B.31C.33D.37
考题
下面程序的运行结果是()。 #define DOUBLE(r) r*r main( ) { int a=1,b=2,temp; temp=DOUBLE(a+b); printf(“%d/n”,temp); } A、3B、5C、7D、9
考题
单选题下面程序的运行结果是()。 #define DOUBLE(r) r*r main( ) { int a=1,b=2,temp; temp=DOUBLE(a+b); printf(“%d/n”,temp); }A
3B
5C
7D
9
热门标签
最新试卷