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