1.Describe a Θ(n lg n)-time algorithm that, given a set S of n integers and another integer x, determines whether or not there exist two elements in S whose sum is exactly x. (Implement exercise 2.3-7.) #include<stdio.h> #include<stdlib.h> void merge(int arr[],int low,int mid,int high){ int i,k; int *tmp=(int*)malloc((high-low+1)*sizeof(int)); int left_low=low; int left_high=mid; int right_low=mid+1; int right_high=high; for(k=0;left_low<=left_high&&right_low<=right_high;k++) { if(arr[left_low]<=arr[right_low]){ tmp[k]=arr[left_low++]; } else{ tmp[k]=arr[right_low++]; } } if(left_low<=left_high){ for(i=left_low;i<=left_high;i++){ tmp[k++]=arr[i]; } } if(right_low<=right_high){ for(i=right_low;i<=right_high;i++) tmp[k++]=arr[i]; } for(i=0;i<high-low+1;i++) arr[low+i]=tmp[i]; } void merge_sort(int a[],int p,int r){ int q; if(p<r){ q=(p+r)/2; merge_sort(a,p,q); merge_sort(a,q+1,r); merge(a,p,q,r); } } int main(){ int a[8]={3,5,8,6,4,1,1}; int i,j; int x=10; merge_sort(a,0,6); printf("after Merging-Sort:\n"); for(i=0;i<7;i++){ printf("%d",a[i]); } printf("\n"); i=0;j=6; do{ if(a[i]+a[j]==x){ printf("exist"); break; } if(a[i]+a[j]>x) j--; if(a[i]+a[j]<x) i++; }while(i<=j); if(i>j) printf("not exist"); system("pause"); return 0; }
上传时间: 2017-04-01
上传用户:糖儿水嘻嘻
The CommScope InstaPATCH® 360 and ReadyPATCH® solutions utilize a standards-compliant multi-fiber connector to provide high density termination capability. The connector is called an MPO (Multi-fiber Push On) connector by the standards. In many cases, multi-fiber connector products are referred to as MTP connectors. This document is intended to clarify the difference between the two terms – MPO and MTP.
上传时间: 2017-04-12
上传用户:asdfghjkl1234567890
Lithium–sulfur (Li–S) batteries with high energy density and long cycle life are considered to be one of the most promising next-generation energy-storage systems beyond routine lithium-ion batteries. Various approaches have been proposed to break down technical barriers in Li–S battery systems. The use of nanostructured metal oxides and sulfides for high sulfur utilization and long life span of Li–S batteries is reviewed here. The relationships between the intrinsic properties of metal oxide/sulfide hosts and electrochemical performances of Li–S batteries are discussed. Nanostructured metal oxides/ sulfides hosts used in solid sulfur cathodes, separators/interlayers, lithium- metal-anode protection, and lithium polysulfides batteries are discussed respectively. Prospects for the future developments of Li–S batteries with nanostructured metal oxides/sulfides are also discussed.
上传时间: 2017-11-23
上传用户:653357637
void IIC_Init(void) { //由于STM8单片机,可以在输入和输出条件下读取IO口状态,故直接设置为输出。 GPIO_Init(IIC_SCL_PORT, IIC_SCL_PIN, GPIO_MODE_OUT_OD_HIZ_SLOW ); GPIO_Init(IIC_SDA_PORT, IIC_SDA_PIN, GPIO_MODE_OUT_OD_HIZ_SLOW ); IIC_SCL_H; IIC_SDA_H; } //产生IIC起始信号 void IIC_Start(void) { IIC_SDA_H; IIC_SCL_H; Delay_us(); IIC_SDA_L; //START:when CLK is high,DATA change form high to low Delay_us(); IIC_SCL_L; //钳住I2C总线,准备发送或接收数据 }
上传时间: 2018-01-10
上传用户:m009988
Fire and Fury。 This article is about the 2018 book. For other uses, see Fire and Fury (disambiguation). The title refers to a quote by Trump about the conflict with North Korea. The book became a New York Times number one bestseller.Fire and Fury: Inside the Trump White House is a 2018 book by Michael Wolff which details the behavior of U.S. President Donald Trump and the staff of his 2016 presidential campaign and White House. The book highlights descriptions of Trump's behavior, chaotic interactions among senior White House staff, and derogatory comments about the Trump family by former White House Chief StrategistSteve Bannon. Trump is depicted as being held in low regard by his White House staff, leading Wolff to state that "100% of the people around him" believe Trump is unfit for office.[1] Reviewers generally accepted Wolff's portrait of a dysfunctional Trump administration, but were skeptical of many of the book's most controversial claims.
上传时间: 2018-02-26
上传用户:Yoobaobao
This article is about the 2018 book. For other uses, see Fire and Fury (disambiguation). The title refers to a quote by Trump abot the conflict with North Korea. The book became a New York Times number one bestseller.Fire and Fury: Inside the Trump White House is a 2018 book by Michael Wolff which details the behavior of U.S. President Donald Trump and the staff of his 2016 presidential campaign and White House. The book highlights descriptions of Trump's behavior, chaotic interactions among senior White House staff, and derogatory comments about the Trump family by former White House Chief StrategistSteve Bannon. Trump is depicted as being held in low regard by his White House staff, leading Wolff to state that "100% of the people around him" believe Trump is unfit for office.[1] Reviewers generally accepted Wolff's portrait of a dysfunctional Trump administration, but were skeptical of many of the book's most controversial claims.
上传时间: 2018-02-26
上传用户:Yoobaobao
一中低功耗的FFT设计的结构概述,采用SDF结构,以及对ROM的简化,使得达到低功耗的目的
标签: low-power processor pipeline FFT
上传时间: 2018-03-26
上传用户:lpyaking
贴片铝电解电容封装库 SMD Aluminum Electrolytic Capacitors VE Features ‧ 3 ~ 16φ, 85℃, 2,000 hours assured ‧ Chip type large capacitance capacitors ‧ Designed for surface mounting on high density PC board. ‧ RoHS Compliance
上传时间: 2018-05-09
上传用户:angel20041401
淋浴器温度控制调节采用MAT LAB 的附加组件Simulink, 仿真系 统的框图如图1 所示。图中的虚线为模糊控制器, 作为二维模糊控制器机构以水的温度偏差temp 和 流量偏差f low 为输入量, 采用模糊推理方法对水 的温度偏差和流量偏差进行整定, 用来确定冷水阀 门和热水阀门的开口大小cold 和hot 以便控制冷 热水的流量, 构成2 输入2 输出的一阶模糊控制系 统; 模糊推理与去模糊化采用MIN - MAX 法及重 心法, 并用MA TLAB 模糊推理工具箱来编辑模糊 控制器。 图1
上传时间: 2018-10-12
上传用户:一只虫虫
DESCRIPTION The Texas Instruments MSP430 family of ultra-low-power microcontrollers consists of several devices featuring different sets of peripherals targeted for various applications. The architecture, combined with five low-power modes, is optimized to achieve extended battery life in portable measurement applications. The device features a powerful 16-bit RISC CPU, 16-bit registers, and constant generators that contribute to maximum code efficiency. The digitally controlled oscillator (DCO) allows wake-up from low-power modes to active mode in less than 1 μs. The MSP430G2x13 and MSP430G2x53 series are ultra-low-power mixed signal microcontrollers with built-in 16- bit timers, up to 24 I/O capacitive-touch enabled pins, a versatile analog comparator, and built-in communication capability using the universal serial communication interface. In addition the MSP430G2x53 family members have a 10-bit analog-to-digital (A/D) converter. For configuration details see Table 1. Typical applications include low-cost sensor systems that capture analog signals, convert them to digital values, and then process the data for display or for transmission to a host system.
上传时间: 2018-12-25
上传用户:ygyh