C/C++
Junruiqwertyuiop
我是一只小菜鸟
展开
-
queue队列的建立及使用,约瑟夫问题C/C++的解决
#include <iostream>#include <stdio.h>#include <string.h>#include <math.h>#include <stdlib.h>using namespace std;int n;void Move(int x,int z);int main(){ int s; scan...原创 2016-11-05 10:40:06 · 975 阅读 · 0 评论 -
简单处理Problem 3223. -- Tyvj 1729 文艺平衡树
Problem Description您需要写一种数据结构(可参考题目标题),来维护一个有序数列,其中需要提供以下操作:翻转一个区间,例如原有序序列是5 4 3 2 1,翻转区间是[2,4]的话,结果是5 2 3 4 1 Input第一行为n,m n表示初始序列有n个数,这个序列依次是(1,2……n-1,n) m表示翻转原创 2017-08-10 16:30:51 · 216 阅读 · 0 评论 -
最大连续子序列求和
C - CTime limit : 1 sMemory limit : 32 mbSubmitted : 120Accepted : 6764bit Integer Format : %lldSubmitProblem Description给定K个整数的序列原创 2017-08-05 19:24:35 · 579 阅读 · 0 评论 -
白盒测试(基本路径法)代码
白盒测试的一种常用方法是基本路径法,根据源代码构造程序流程图,转换为控制流图,得到基本路径,进而为每条基本路径设计测试用例。基本路径法的一个关键步骤是识别出所有的基本路径。本次作业要求你写一个C++程序:输入:待测程序的控制流图输出:圈复杂度、基本路径集合基本要求输入:待测程序的控制流图包含多行数据。第1行表示控制流图中的入口节点的编号,表示程序由此开始执行原创 2018-01-14 11:01:35 · 7530 阅读 · 0 评论 -
人工智能猴子摘香蕉问题
猴子摘香蕉问题:一个房间里,天花板上挂有一串香蕉,有一只猴子可在房间里任意活动(到处走动,推移箱子,攀登箱子等)。设房间里还有一只可被猴子移动的箱子,且猴子登上箱子时才能摘到香蕉,问猴子在某一状态下(设猴子位置为A,箱子位置为B,香蕉位置在C),如何行动可摘取到香蕉。代码样例:#includestruct State{ int monkey; //-1:Monkey at A原创 2018-01-14 11:24:45 · 17645 阅读 · 8 评论 -
C语言定义字符串“双引号”和字符“单引号”
最近写编译器的时候发现一个问题:就是对于字符的匹配例如对于双引号,如果是一个字符,那么'"'就可以了,但如果字符串"""就会报错。所以,使用转义字符例如\' ,\" ,等等所有的ASCII码都可以用“\”加数字(一般是8进制数字)来表示。而C中定义了一些字母前加"\"来表示常见的那些不能显示的ASCII字符,如\0,\t,\n等,就称为转义字符,因为后面的字符,都不是它本来的ASCII字符意思了...原创 2018-03-27 11:11:41 · 35518 阅读 · 0 评论 -
对于文件的读写操作处理,指针头
对于文件的读写操作#include<stdio.h>#include "scanner.h"int main(){ FILE * file; file = fopen("abc.txt","r"); if(file == NULL) printf("The file is note exist!"); WORD * wPtr = wordScanner(file);...原创 2018-03-27 11:12:14 · 904 阅读 · 0 评论 -
C++读入文件
C++ 一行一行读:#include<iostream>#include<fstream>int main(int argv,char *arg[]) { fstream f("dictionary.txt");//创建一个fstream文件流对象 vector<string> words; //创建一个vector<...原创 2018-04-05 14:23:58 · 1403 阅读 · 1 评论 -
把一个vector里的元素全部放入另外一个vector
把一个vector里的元素全部放入另外一个vectorstd::vector<int> src;std::vector<int> dest;dest.insert(dest.end(), src.begin(), src.end());原创 2018-04-13 14:28:18 · 7343 阅读 · 0 评论 -
VS系统的变量错误 error:变量()不明确
定义一个全局变量move然后在后面我们会发现这个原因是因为VS内库有对move的定义,所以才会“不明确”这个时候只需要改一下变量名就可以了,比如moveT这样就成功不会报错了。...原创 2018-04-26 19:13:18 · 3825 阅读 · 0 评论 -
error C2065: “SOCKET”: 未声明的标识符
error C2065: “SOCKET”: 未声明的标识符error C2065: “SOCKET”: 未声明的标识符添加以下头文件即可:#include <Winsock2.h> //#include <Winsock.h>?转载 2018-05-05 12:30:46 · 2664 阅读 · 4 评论 -
fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shar
fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]原因:常规里面是静态mfc,多线程调试是MDd(多线程动态调试)解决:将MDd改成...转载 2018-05-05 12:48:04 · 2005 阅读 · 0 评论 -
哈工大 计算机网络 实验4 ipv4收发实验 附两份代码
在INET上编译执行注意的是,该软件只支持32位系统一般在win7-32位1. 默认值安装 WinPcap_4_0_2.exe 软件。 2. 双击 SimplePAD-客户端 v2.exe。将客户端解压到本地文件夹。 3. 进入解压目录中的\expsys\bin 目录下,双击运行客户端 INEP.exe。 4. 初次登录请选择菜单中“系统”—“系统设置”配置服务器 IP 地址 5. 服务器访...原创 2018-05-12 15:15:20 · 4607 阅读 · 0 评论 -
贪心A
A - 贪心ASubmitProblem DescriptionFriends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged ata1 percent and second one is charged ata...原创 2017-08-02 08:56:58 · 196 阅读 · 0 评论 -
A - A简单简单
Time limit : 1 sMemory limit : 64 mbSubmitted : 29Accepted : 2564bit Integer Format : %lldSubmitProblem DescriptionA big marathon is held on Al-Maza R原创 2017-07-23 14:07:59 · 289 阅读 · 0 评论 -
2016 Pacific Northwest Region Programming Contest—Division 2 Problem S — limit 1 second Gravity
#include#include#include #includeusing namespace std;int main(){int m,n;char map[50][50];intbegin[50][50];//int res[50][50];scanf("%d %d",&m,&n);memset(begin,0,sizeof(begin));//memset(res,0,sizeof(r原创 2017-07-21 19:17:17 · 600 阅读 · 0 评论 -
二叉树及其应用
实验内容:假设自上而下按层次,自左至右输入每个结点的一个三元组(N, P, L/R)。其中N为本结点的元素,P为其父结点,L指示N为P 的左孩子,R指示N为P的右孩子。试写一个建立二元树在内存的双链表示算法,并实现先根、中根、后根以及层序遍历算法。样例输出(二选一):a -1-1b a Lg a Rc b Ld b Rh g Le d Lf d R-1 1 -1-12 1 L3 1 R4 2 L5...原创 2016-11-20 17:26:56 · 547 阅读 · 0 评论 -
POJ 3624 Charm Bracelet
POJ3624:Charm BraceletDescriptionBessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from theN (1 ≤ N ≤ 3,402) availa...原创 2016-11-25 22:20:27 · 576 阅读 · 0 评论 -
调试实现快速排序算法
快速排序在C语言中一般以调用qsort函数为主自写qsort函数基础功能#include <stdio.h>#include <stdlib.h> void swap(int *x,int *y){ int temp; temp = *x; *x = *y; *y = temp;}void quicksort(int list[],int m,int n){...原创 2017-01-01 17:50:49 · 494 阅读 · 0 评论 -
POJ1251 Jungle Roads
Jungle RoadsPOJ - 1251The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes...原创 2017-01-01 20:07:14 · 290 阅读 · 0 评论 -
最简单的加法运算1001,1002
acm.hit.edu.cn1001A+Bfor each pair of integers A and B ( 0 <= A,B <= 10) , Output the result of A+B on a single line.Sample Input 1 23 4Sample Output37Sample Code#include in原创 2017-01-18 21:17:04 · 619 阅读 · 0 评论 -
Mixing Milk
Mixing MilkSince milk packaging is such a low margin business, it is important to keep the price of the raw product (milk) as low as possible. Help Merry Milk Makers get the milk they ne原创 2017-01-19 15:39:37 · 302 阅读 · 0 评论 -
对于数字位数的判断及回文数的判断+Prime Palindromes
一、判断数位:int judgenum(int x){ int c; c = 0; while(x>1) { x=x/10; c++; } return c;}许多人使用log的算法,即(由于math.h不支持lg,所以要用log(a)/log(b)的用法)log(a)/log(10)的方法,但这样有两个问题,1.造成较大误差原创 2017-01-19 22:05:34 · 468 阅读 · 0 评论 -
Simple and Naive
Simple and Naive#include #include #includeint main(){ int s,n,m,t,result; scanf("%d",&s); while(s--) { scanf("%d",&n); m=n/4; t=n%4;原创 2017-01-19 23:31:33 · 573 阅读 · 0 评论 -
C/C++矩阵传参数问题
例一:int **example_data , *test_data ,*distance; //allocate space in heap for the variable example_data = new int*[N]; for(int i=0;i { example_data[i] = new int[D]; } test_data = new原创 2017-03-18 13:56:29 · 2248 阅读 · 0 评论 -
最长公共子串与最长公共子序列
本文转载于http://blog.csdn.net/hackbuteer1/article/details/6686931子字符串的定义和子序列的定义类似,但要求是连续分布在其他字符串中。比如输入两个字符串BDCABA和ABCBDAB的最长公共字符串有BD和AB,它们的长度都是2。 最长公共子字符串共有两种解决方法,下面具体说说我的思路方法一: Lon转载 2017-07-08 10:02:37 · 298 阅读 · 0 评论 -
2016 Pacific Northwest Region Programming Contest—Division 2 Problem M
Problem M — limit 1 second AlphabetA string of lowercase letters is called alphabetical if deleting zero or more of its letters can result in the alphabet string “abcdefghijklmnopqrstuvwxyz”.Given原创 2017-07-21 19:20:30 · 1168 阅读 · 0 评论 -
2016 Pacific Northwest Region Programming Contest—Division 2 Problem R — limit 1 second Equality
Problem R — limit 1 second EqualityYou are grading an arithmetic quiz. The quiz asks a student for the sum of the numbers. Determine if the student taking the quiz got the question correct.Input原创 2017-07-21 19:22:49 · 564 阅读 · 0 评论 -
手持两把锟斤拷, 口中疾呼烫烫烫, 脚踏千朵屯屯屯, 笑看万物锘锘锘
锟斤拷的来历 GBK与UTF-8 Unicode和老编码体系的转化进程中,一定有一些字,用Unicode是没法表示的,Unicode官方用了一个占位符来表示这些文字,这就是:U+FFFD REPLACEMENT CHARACTER。那么U+FFFD的UTF-8编码出来,恰恰是 "\xef\xbf\xbd"。假如这个"\xef\xbf\xbd",反复屡次,例如 "\xef\xbf\xbd...原创 2018-11-08 14:54:07 · 7233 阅读 · 0 评论