1.完成猜数字游戏。
include
include
include
include < stdio.h >
int main()
{
int arr [] = { 1, 2, 3, 4, 5, 6, 7 };
int left = 0;
int right = sizeof(arr)/sizeof(arr[0])-1;
int key = 3;
int mid = 0;
while ( left <= right )
{
mid = ( left+right )/2;
if ( arr[mid]>key)
{
right = mid-1;
}
else if ( arr[mid]
include < stdio.h >
include < string.h >
int main()
{
char psw[10] = {0};
int i = 0;
for ( i=0; i<3; i++ )
{
printf ( “请输入密码:” );
scanf ( “%s”,psw );
if ( strcmp ( psw,”123456” ) ==0 )
{
break;
}
else
{
printf ( “密码错误,请重新输入\n” );
}
}
if ( i==3 )
{
printf ( “退出系统\n” );
}
else
{
printf ( “登录成功\n” );
}
system ( "pause" );
return 0;
}
4.编写一个程序,可以一直接收键盘字符,如果是小写字符就输出对应的大写字符,如果接收的是大写字符,就输出对应的小写字符,如果是数字不输出。