相关题目
设有程序段
int k = 10;
while ( k = 0 ) k= k-1 ;
则下面描述中正确的是( ) 。
设有以下程序段
int x=0,s=0;
whlle ( ! x ! = 0 ) s + = ++x;
printf (“% d”, s );
则( ) 。
语句while ( !E ) ; 中的表达式中!E等价于( ) 。
下面程序段的运行结果是( ) 。
a =1 ; b= 2 ; c = 2 ;
while ( a < b < c ){t=a;a=b;b=t;c--;}
printf (“% d , % d , % d”, a , b , c);
下面程序段的运行结果是() 。
x = y = 0 ;
while ( x < 15 ) y + + , x +=++ y;
printf ( " % d , % d " , y , x );
下面程序段的运行结果是( ) 。
int n = 0 ;
while( n + + <=2 ); printf("%d",n);
设有以下程序段,下面描述正确的是( )。
t=0;
while ( printf ( “*”))
{t + + ;
if ( t < 3 ) break ;
}
下面程序的功能是将从键盘输入的一对数, 由小到大排序输出。 当输入一对相等数时结束循环, 则语句while后面应为( )。
#include
main()
{int a , b , t ;
scanf (“% d % d”,&a,&b);
while (( ))
{
if ( a > b )
{ t = a ; a = b ; b = t ; }
printf ( “%d , % d \ n”, a , b ) ;
scanf (“% d % d”,&a,&b);
}}
下面程序的功能是从键盘输入的一组字符中统计出大写字母的个数m和小写字母的个数n , 并输出m 、 n 中的较大者, 请选择填空。
#include
main ( )
{
int m = 0 , n = 0 ;
char c ;
while ( (( )) ! = ‘\n’)
{
if ( c>=’A’&& c<=’Z’) m + + ;
if ( c>=‘a’&& c<= ' z ') n + + ;
}
printf ( " % d \ n " , m < n ?n:m);
}
下面程序的功能是将小写字母变成对应大写字母后的第二个字母。其中y 变成A , z 变成B , 请选择填空。
# include
main ( )
{ char c ;
while ( ( c = getchar ( ) ) != ‘\ n ' )
{ if ( c > = ' a ‘&&c<=’z ' )
{ ( ) ;
if ( c >’Z’&&c<= ' Z ' + 2 )
c -=26 ;
}
printf ( " % c " , c ) ;
}
}
