当前位置:网站首页>暑期学前作业
暑期学前作业
2022-08-10 05:02:00 【米奇拉莫斯啦米老鼠】
1.插入排序
(1)
#include <stdio.h>
void print(int a[],int n)
{
for(int i=0;i<n;i++)
{
printf("%d",a[i]);
printf("\t");
}printf("\n");
}
void insertion_sort(int a[],int n)
{ print(a,n);
for(int i=1;i<n;i++)
{
int key=a[i];
int j=i-1;
while(j>=0&&a[j]>key)
{
a[j+1]=a[j];
j--;
}
a[j+1]=key;
print(a,n);
}
}
int main()
{
int a[1000];
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
insertion_sort(a,n);
}
这种写法没有办法,无限输入,最近看书看到了vector,尝试的用c++写了一下,还没有搞懂vector做参数的做法,但是可以实现无限输入。
(2)
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> a;
int n;
while(1)
{cin>>n;
a.push_back(n);
if(cin.get()=='\n')
break;
}
int len=a.size();
for(int i=1;i<len;i++)
{
int key=a[i];
int j=i-1;
while(j>=0&&a[j]>key)
{
a[j+1]=a[j];
j--;
}
a[j+1]=key;
for(int i=0;i<len;i++)
{
cout<<a[i]<<" ";
} cout<<endl;
}
}
2.输出二进制
#include <stdio.h>
void change(int x)
{if(x>0)
{change(x/2);
printf("%d",x%2);
}
}
int main()
{int x;
printf("Please input a number.\n");
scanf("%d",&x);
change(x);
}
3.判断素数
#include <stdio.h>
int judge(int x)
{
for(int i=2;i<=x-1;i++)
{if(x%i==0)
{
return 0;break;}
else continue;
}return 1;
}
int main()
{
int n;
int z=1;
while(z==1)
{ printf("Please input a number.\n");
scanf("%d",&n);
if(judge(n)==1)
printf("This is a prime number.\n ");
else printf("This is not a prime number.\n");
printf("If you want to continue please input 1 and if you want to stop please input 0.\n");
scanf("%d",&z);
}
printf("over");
}
4.支持La Tex的Markdown语句,编写数学公式

5.学习心得与期望
最近接触了Markdown,发现十分好用,在电脑上下载了Obsidian在里面下载了插件,拿来记一些代码笔记和数学笔记,就是还不太熟练用Markdown来写,还在慢慢摸索,至少最近效率提高了一些。期望是把知识学扎实了,多多思考,在数学方面由于个人原因,前面学期的学习内容都没有很好掌握,希望再接下来的假期时间,抓紧查漏补缺。
边栏推荐
- webrtc学习--一对一通话
- The time for flinkcdc to read pgsql is enlarged. Does anyone know what happened? gmt_create':1
- 万字总结:分布式系统的38个知识点
- 60行从零开始自己动手写FutureTask是什么体验?
- JVM内存模型
- About the problem that the mongodb driver count method of rust cannot be used with the near condition
- 文献 | 关于心理活动符号学,你知道多少?
- 电流探头如何设置示波器参数
- LeetCode 6138. 最长理想子序列 动态规划
- 释放高通量算力价值潜能 JASMINER持续领跑 Web3 市场
猜你喜欢

兴盛优选监控场景的时序数据库选型与落地实践

leetcode每天5题-Day11

【论文笔记】Prototypical Contrast Adaptation for Domain Adaptive Semantic Segmentation

告诉你如何从keil工程知道使用了多少RAM和ROM空间

小影科技IPO被终止:年营收3.85亿 五岳与达晨是股东

Unity实现UI的边缘检测和拖拽拉伸功能

虚假新闻检测论文阅读(八):Assessing Arabic Weblog Credibility via Deep Co-learning

Joomla漏洞复现

3、ROS工作空间的创建

什么是“大小端字节序”存储模式?
随机推荐
2022 security officer C certificate test and simulation test in shandong province
redis basic data types
取消了这次
域名DNS解析工具ping/nslookup/dig/host
openvino 安装(01)
用.bat文件做Airtest脚本的多设备批量运行
线程(中):线程安全
万字总结:分布式系统的38个知识点
2022 R2 transportable pressure vessel filling operation examination question bank simulation platform
Thread.sleep, Thread.yield 作用解释
【无标题】
Unity实现UI的边缘检测和拖拽拉伸功能
解决“#231-D declaration is not visible outside of function”告警方法
【无标题】
B+树与B树的区别、Hash索引与B+树索引的区别
mysql常用命令有什么
From entry to mastery of PHPCMS imitation station, Xiaobai is enough to watch this set of courses
goland里的异常处理
用 PySpark ML 构建机器学习模型
Acwing 59. 把数字翻译成字符串 计数类DP