首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

小弟我的美女徒弟让小弟我给她做题,小弟我实在没时间.非常简单的题目,那个大哥帮帮忙.晚上做好

2012-03-11 
我的美女徒弟让我给她做题,我实在没时间.非常简单的题目,那个大哥帮帮忙.晚上做好.一、选择题:1、C++源程序

我的美女徒弟让我给她做题,我实在没时间.非常简单的题目,那个大哥帮帮忙.晚上做好.
一、         选择题:
1、C++源程序文件的扩展名是:a
A)   .CPP                 B)   .C                 C)   .DLL                   D)   .EXE

2、将小写字母n赋值给字符变量one_char,正确的操作是:b
A)   one_char   =   ‘\n’;             B)   one_char   =   “n”;
C)   one_char   =   110;             D)   one_char   =   ‘N’;

3、整型变量i定义后赋初值的结果是:b
      int   i=2.8*6;
A)   12           B)   16           C)   17         D)   18

4、下列表达式的值为false的是:c
A)   1 <3   &&   5 <7             B)   !(2> 4)           C)   3&0&&1         D)   !(5 <8)||(2 <8)

5、设int   a=10,   b=11,   c=12;表达式(a+b) <c&&b==c的值是:B
A)   2               B)   0               C)   –2             D)   1

6、下列程序执行完后,x的值是:c
    int   x=0;
    for   (int   k=0;k <90;   k++)
if   (k)     x++;
A)   0                   B)   30             C)   89           D)   90

7、下列程序段循环次数是:d
    int   x   =   -10;
    while   (++x)     cout < <x < <endl;
A)   9                 B)   10             C)   11                   D)   无限

8、表示“大于10而小于20的数“,正确的是:c
A)   10 <x <20       B)   x> 10||x <20       C)   x> 10&x <20           D)   !(x <=10||x> =20)

9、若整型变量x=2,则表达式x < <2的结果是:d
A)   2                 B)   4           C)   6             D)   8

10、设a=1,   b=2,则(a++)+b与a+++b这两个表达式的值分别为:c
A)   3,   3         B)   3,   4           C)   4,   3         D)   4,4

二、程序填空题。
1、下列程序计算1000以内能被3整除的自然数之和。
#include   <iostream.h>
void   main(   )
{       int   x=1,   sum;
sum=0_______;
while   (true)
{       if   (x> 1000)     break;
        if   (x%3==0)   sum+=x;
        x++;
}
cout < <sum < <endl;
}
三、假定输入10个整数:32,64,53,87,54,32,98,56,98,83。下列程序的输出结果是?
#include   <iostream.h>
void   main(   )
{       int   a,b,c,x;
      a=b=c=0;
      for   (int   k=0;   k <10;   k++)
      {       cin> > x;
switch(x%3)
{       case   0:     a+=x;   break;


        case   1:     b+=x;   break;
        case   2:     c+=x;   break;
}
      }
cout < <a < <”,” < <b < <”,” < <c < <endl;
}


32,32,32
64,64,0
53,53,53
87,0,0
54,0,0
32,32,32
98,98,98
56,56,56  
98,98,98
83,83,83  


四、写出下列程序运行结果。
#include   <iostream.h>
void   main(   )
{       int   j,k;
for   (j=5;   j> 0;   j--)
{     for   (k=j;   k> 0;   k--)
          cout < <”*”;
    cout < <endl;
}
}
*

五、写出下列程序的运行结果。
#include   <iostream.h>
#include   <iomanip.h>
void   main()
{      
cout < <”x_width=” < <cout.width() < <endl;
cout < <”x_fill=” < <cout.fill() < <endl;
cout < <”x_precision=” < <cout.precision() < <endl;
cout < <123 < <”   ” < <123.45678 < <endl;
cout < <”***x_width=10,x_fill=&,x_precision=8***” < <endl;
cout.width(10);
cout.fill(‘&’);
cout.precision(8);
cout < <123 < <”   “ < <123.45678 < <endl;
cout.setf(ios::left);
cout < <123 < <”   “ < <123.45678 < <endl;
cout.width(10);
cout < <123 < <”   “ < <123.45678 < <endl;
cout < <”x_width=” < <cout.width() < <endl;
cout < <”x_fill=” < <cout.fill() < <endl;
cout < <”x_precision=” < <cout.precision() < <endl;
}


六、程序题。
1、         编写程序,求解方程ax2+bx+c=0的根。


2、         编写程序输出所有的水仙花数。所谓水仙花数是指一个三位数,其各位数的立方和等于该数。例如:153=13+53+33。
main()
{
  Int   x=0,y=0,z=0,k=0;
for(x=0;x <10;x++)
{for(y=0;y <10;y++)
{for(z=0;z <10;z++)
}}if(x*x*x+y*y*y+z*z*z=100*x+10*y+z)k=100*x+10*y+z;
cout < <k < <endl
}

3、         编写程序,计算s=1+(1+2)+(1+2+3)+…+(1+2+3+…+n)的值。

4、某百货公司为了促销,采用购物打折的办法。
(1)         在1000元以上者,按九五折优惠;
(2)         在2000元以上者,按九折优惠;
(3)         在3000元以上者,按八五折优惠;
(4)         在5000元以上者,按八折优惠。
编写程序,输入购物款数,计算并输出优惠价。(要求用switch语句编写)
main()
{
      Int       x   ,y=0
cin> > x;
if(x <1000)   case=0;
if(x=> 1000&&x <2000)case=1;
if(x=> 2000&&x <3000)case=2;
if(x=> 3000&&x <5000)case=3;
if(x=> 5000)case=4;
swith()
{  
case=0:   y=x;   break;
case=1:   y=0.95*x;   break;
case=2:   y=0.9*x;   break;
case=3:   y=0.85*x;   break;
            case=4:   y=0.8*x;   break;
}
cout < <y < <endl;
}

5、         将一张一元纸币兑换成一分、二分和五分的硬币,假定每种至少一枚,计算共有多少种兑换法并打印出各种兑换法。
main()
{
int   x,y,z,k=0;
for(x=1;x <99;x++)
{for(y=1;y <99;y++)
{for(z=1;z <99;z++)if(x+2*y+5*z=100){k++;
}
}
}
}

6、“同构数”是指这样的整数:它恰好出现在其平方数的右端。如:376*376=141376。请找出10000以内的全部“同构数”。



------解决方案--------------------


进来看美女徒弟
[解决办法]
LZ把美女徒弟QQ放出来。。。
[解决办法]
看来楼主失误了,莫提徒弟是美女~~~~
[解决办法]
原来楼主,估计你的徒弟也美不到哪里去,还是高挂免战牌!
[解决办法]
//把没做的做一下

五、写出下列程序的运行结果。
#include <iostream.h>
#include <iomanip.h>
void main()
{
cout < <”x_width=” < <cout.width() < <endl;
cout < <”x_fill=” < <cout.fill() < <endl;
cout < <”x_precision=” < <cout.precision() < <endl;
cout < <123 < <” ” < <123.45678 < <endl;
cout < <”***x_width=10,x_fill=&,x_precision=8***” < <endl;
cout.width(10);
cout.fill(‘&’);
cout.precision(8);
cout < <123 < <” “ < <123.45678 < <endl;
cout.setf(ios::left);
cout < <123 < <” “ < <123.45678 < <endl;
cout.width(10);
cout < <123 < <” “ < <123.45678 < <endl;
cout < <”x_width=” < <cout.width() < <endl;
cout < <”x_fill=” < <cout.fill() < <endl;
cout < <”x_precision=” < <cout.precision() < <endl;
}

x_width=0
x_fill=
x_precision=6
123 123.457
***x_width=10,x_fill=&,x_precision=8***
&&&&&&&123 123.45678
123 123.45678
123&&&&&&& 123.45678
x_width=0
x_fill=&
x_precision=8


六、程序题。
1、 编写程序,求解方程ax2+bx+c=0的根。
#include <stdio.h>
#include <math.h>
float x1,x2,p,q,d;
float great_than_zero(float,float);
float equql_to_zero(float,float);
float smaller_than_zero(float,float);
main()
{
float a,b,c;
printf( "Enter a,b,c: ");
scanf( "%f%f%f ",&a,&b,&c);
d=b*b-4*a*c;
if(d> 0)
{
great_than_zero(a,b);
printf( "x1=%5.2f\tx2=5.2f\n ",x1,x2);
}
else if(d==0)
{
equal_to_zero(a,b);
printf( "x1=x2=%6.2f\n ",x1);
}
else
{
smaller_than_zero(a,b);
printf( "x1=%5.2f+i%5.2f\n ",p,q);
printf( "x2=%5.2f-i%5.2f\n ",p,q);
}
return 0;
}
float great_than_zero(float x,float y)
{
x1=(-y+sqrt(d))/(2*x);
x2=(-y-sqrt(d))/(2*x);
return ;
}

float equql_to_zero(float x,float y)
{
x1=(-y)/(2*x);
return;
}

float smaller_than_zero(float x,float y)
{
p=-y/(2*x);
q=sqrt(-d)/(2*x);
return;
}


6、“同构数”是指这样的整数:它恰好出现在其平方数的右端。如:376*376=141376。请找出10000以内的全部“同构数”。

int isomorphic(int a)
{
int b,n=0,temp,square;
temp=a;
square=a*a;
do{
n++;
}while(a/=10);
b=square%(int)pow(10,n);

if(temp==b)
return 1;
return 0;
}

[解决办法]
/*6、“同构数”是指这样的整数:
它恰好出现在其平方数的右端。
如:376*376=141376。
请找出10000以内的全部“同构数”。*/
# include "iostream.h "
void main()
{
long int x;
int y=0;
for (int i=1;i <10000;i++)
{
x=i*i;
if ( i-(x%10)==0)
y=1;
else if ( i-(x%100)==0)
y=1;


else if (( i-(x%1000) )==0)
y=1;
else if (( i-(x%10000) )==0)
y=1;


if (y==1)
{
cout < <i < < "x " < <i < < "= " < <x < <endl;
}
y=0;

}
初学者更容易理解些~~

热点排行