一塌糊涂的code!!!

1.完成猜数字游戏。
2.完成折半查找代码的编写和探索。
3.编写代码模拟三次密码输入的场景。
4.编写一个程序,可以一直接收键盘字符,如果是小写字符就输出对应的大写字符,如果接收的是大写字符,就输出对应的小写字符,如果是数字不输出。

 

#include<stdio.h>


#include<stdlib.h>

int main()

{

int m;

m=getchar();

if(48<=m<=57)

{

 ;



}

if((m>=65)&&(m<=90))

{

printf("%c\n",m+32);

}

if(97<=m<=122)

{

printf("%c\n",m-32);



}

system("pause");



return 0;








 #include<stdio.h>

#include<string.h>

#include<stdlib.h>

int main()

{

char arr[7];

int i=0;

for(i=0;i<3;i++)

{

printf("请输入密码:>");

scanf("%s",arr);

if(0==strcmp(arr,"123456"))

{

printf("登陆成功!\n");

break;

}

}

if(i==3)

{

printf("登录失败!\n");

exit(0);

}

system("pause");

return 0;








 #include<stdio.h>

#include<stdlib.h>

int main()

{

int arr[10] = {0,1,2,3,4,5,6,7,8,9};

int x;

int left = 0;

int right = sizeof(arr) / sizeof(arr[0]) - 1;

int i = 0;

scanf("%d", &x);

while (left <= right)

{

int mid = (right - left) / 2 + left;

if (x>arr[mid])

{

left = mid + 1;

}

else if (x<arr[mid])

{

right = mid - 1;

}

else

{

printf("%d\n", mid);

break;

}

}

system("pause");

return 0;

}






 #include<stdio.h>

#include<time.h>

#include<stdlib.h>

int main()

{

int ret;

int n=0;

printf("请猜会输出多少:");

    scanf("%d",&n);

srand((unsigned)time(NULL));

ret=rand()%101;

printf("ret=%d\n",ret);

if(n<ret)

{

printf("真笨,哈哈,猜小了!\n");

}

else if(n>ret)

{

printf("笨猪,猜大了!\n");

}

else

{

printf("你真棒,猜对了!\n");

}

    system("pause");

return 0;








 #include <stdio.h>

int main()

{

 int m,n; //定义俩个变量

 int temp; //中间变量

 scanf("%d%d",&m,&n);//读取两个变量的值

 while(m%n!=0)//循环求最大公约数

 { 

  temp=n;

  n=m%n;

  m=temp;

 }

 printf("%d\n",n); //打印出最大公约数

 return 0;
















  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值