一塌糊涂的code!!!

2024-01-15 23:48
文章标签 code 一塌糊涂

本文主要是介绍一塌糊涂的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;
















这篇关于一塌糊涂的code!!!的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/610606

相关文章

Debugging Lua Project created in Cocos Code IDE creates “Waiting for debugger to connect” in Win-7

转自 I Installed Cocos Code IDE and created a new Lua Project. When Debugging the Project(F11) the game window pops up and gives me the message waiting for debugger to connect and then freezes. Also a

LLVM入门2:如何基于自己的代码生成IR-LLVM IR code generation实例介绍

概述 本节将通过一个简单的例子来介绍如何生成llvm IR,以Kaleidoscope IR中的例子为例,我们基于LLVM接口构建一个简单的编译器,实现简单的语句解析并转化为LLVM IR,生成对应的LLVM IR部分,代码如下,文件名为toy.cpp,先给出代码,后面会详细介绍每一步分代码: #include "llvm/ADT/APFloat.h"#include "llvm/ADT/S

VS Code 调试go程序的相关配置说明

用 VS code 调试Go程序需要在.vscode/launch.json文件中增加如下配置:  // launch.json{// Use IntelliSense to learn about possible attributes.// Hover to view descriptions of existing attributes.// For more information,

code: 400, msg: Required request body is missing 错误解决

引起这个错误的原因是,请求参数按照get方式给。 应该给json字符串才对 补充: 1. @RequestBody String resource 加@RequestBody必须给json字符串,否则会报错400,记如标题错误。 不加这个的进行请求的话,其实post和get就没有什么区别了。 2. List<String> indexCodes=(List<String>)json.

iOS项目发布提交出现invalid code signing entitlements错误。

1、进入开发者账号,选择App IDs,找到自己项目对应的AppId,点击进去编辑, 2、看下错误提示出现  --Specifically, value "CVYZ6723728.*" for key "com.apple.developer.ubiquity-container-identifiers" in XX is not supported.-- 这样的错误提示 将ubiquity

解决服务器VS Code中Jupyter突然崩溃的问题

问题 本来在服务器Anaconda的Python环境里装其他的包,装完了想在Jupyter里写代码验证一下有没有装好,一运行发现Jupyter崩溃了!?报错如下所示 Failed to start the Kernel. ImportError: /home/hujh/anaconda3/envs/mia/lib/python3.12/lib-dynload/_sqlite3.cpython-

Behind the Code:与 Rakic 和 Todorovic 对话 OriginTrail 如何实现 AI 去中心化

原文:https://www.youtube.com/watch?v=ZMuLyLCtE3s&list=PLtyd7v_I7PGnko80O0LCwQQsvhwAMu9cv&index=12 作者:The Kusamarian 编译:OneBlock+ 随着人工智能技术的飞速发展,一系列前所未有的挑战随之而来:模型的衰退与互联网的潜在威胁愈发明显。AI 的增长曲线可能因训练过程中的瓶颈而趋于平

冒泡排序和鸡尾酒排序(code)

昨天回顾了下冒泡排序和鸡尾酒排序,用面向对象的方式写了一下,并且优化了代码,记录一下~ 一、冒泡排序 # 冒泡排序class BubbleSort(object):def __init__(self, data_list):self.data_list = data_listself.length = len(data_list)# 简单粗暴的排序方式def b_sort(self):d

编译时出现错误 -- clang: error: linker command failed with exit code 1 (use -v to see invocation)

出现这个错误的原因有多种,常见的是因为某些文件的缺失或者是文件的重复导致的。 这类错误查看的关键在于其上一行的文字。 对于文件缺少而导致错误的情况: 例如上图中的示例,其上一行文字为 ld:library not found for -lrxl,可以看出是缺失了某一文件而导致的错误,这行文字中的最后“ -lrxl ”:-l 代表着其前缀是“lib”,连着后面的 rxl,其名称为 libr

GCDAsyncUdpSocket 使用时出现错误 Domain=NSPOSIXErrorDomain Code=13 Permission denied

完整的错误描述为: Domain=NSPOSIXErrorDomain Code=13 "Permission denied" UserInfo={NSLocalizedDescription=Permission denied, NSLocalizedFailureReason=Error in send() function.} 原始代码是这样的: clientBroadcast