bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

java視頻折半代碼 java實現(xiàn)視頻剪輯

求JAVA視頻播放器代碼

import java.awt.BorderLayout;

創(chuàng)新互聯(lián)2013年開創(chuàng)至今,是專業(yè)互聯(lián)網(wǎng)技術服務公司,擁有項目成都做網(wǎng)站、成都網(wǎng)站設計網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元白塔做網(wǎng)站,已為上家服務,為白塔各地企業(yè)和個人服務,聯(lián)系電話:028-86922220

import java.awt.Component;

import java.awt.FileDialog;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.ItemEvent;

import java.awt.event.ItemListener;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import javax.media.ControllerClosedEvent;

import javax.media.ControllerEvent;

import javax.media.ControllerListener;

import javax.media.EndOfMediaEvent;

import javax.media.Manager;

import javax.media.MediaLocator;

import javax.media.NoPlayerException;

import javax.media.Player;

import javax.media.PrefetchCompleteEvent;

import javax.media.RealizeCompleteEvent;

import javax.media.Time;

import javax.swing.JCheckBoxMenuItem;

import javax.swing.JFrame;

import javax.swing.JMenu;

import javax.swing.JMenuBar;

import javax.swing.JMenuItem;

import javax.swing.SwingUtilities;

import javax.swing.UIManager;

public class JMFMediaPlayer extends JFrame implements ActionListener,

ControllerListener, ItemListener {

// JMF的播放器

Player player;

// 播放器的視頻組件和控制組件

Component vedioComponent;

Component controlComponent;

// 標示是否是第一次打開播放器

boolean first = true;

// 標示是否需要循環(huán)

boolean loop = false;

// 文件當前目錄

String currentDirectory;

// 構造方法

public JMFMediaPlayer(String title) {

super(title);

addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent e){

// 用戶點擊窗口系統(tǒng)菜單的關閉按鈕

// 調用dispose以執(zhí)行windowClosed

dispose();

}

public void windowClosed(WindowEvent e){

if (player != null){

// 關閉JMF播放器對象

player.close();

}

System.exit(0);

}

});

// 創(chuàng)建播放器的菜單

JMenu fileMenu = new JMenu("文件");

JMenuItem openMemuItem = new JMenuItem("打開");

openMemuItem.addActionListener(this);

fileMenu.add(openMemuItem);

// 添加一個分割條

fileMenu.addSeparator();

// 創(chuàng)建一個復選框菜單項

JCheckBoxMenuItem loopMenuItem = new JCheckBoxMenuItem("循環(huán)", false);

loopMenuItem.addItemListener(this);

fileMenu.add(loopMenuItem);

fileMenu.addSeparator();

JMenuItem exitMemuItem = new JMenuItem("退出");

exitMemuItem.addActionListener(this);

fileMenu.add(exitMemuItem);

JMenuBar menuBar = new JMenuBar();

menuBar.add(fileMenu);

this.setJMenuBar(menuBar);

this.setSize(200, 200);

try {

// 設置界面的外觀,為系統(tǒng)外觀

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

SwingUtilities.updateComponentTreeUI(this);

} catch (Exception e) {

e.printStackTrace();

}

this.setVisible(true);

}

/**

* 實現(xiàn)了ActionListener接口,處理組件的活動事件

*/

public void actionPerformed(ActionEvent e) {

if (e.getActionCommand().equals("退出")) {

// 調用dispose以便執(zhí)行windowClosed

dispose();

return;

}

FileDialog fileDialog = new FileDialog(this, "打開媒體文件", FileDialog.LOAD);

fileDialog.setDirectory(currentDirectory);

fileDialog.setVisible(true);

// 如果用戶放棄選擇文件,則返回

if (fileDialog.getFile() == null){

return;

}

currentDirectory = fileDialog.getDirectory();

if (player != null){

// 關閉已經(jīng)存在JMF播放器對象

player.close();

}

try {

// 創(chuàng)建一個打開選擇文件的播放器

player = Manager.createPlayer(new MediaLocator("file:"

+ fileDialog.getDirectory() + fileDialog.getFile()));

} catch (java.io.IOException e2) {

System.out.println(e2);

return;

} catch (NoPlayerException e2) {

System.out.println("不能找到播放器.");

return;

}

if (player == null) {

System.out.println("無法創(chuàng)建播放器.");

return;

}

first = false;

this.setTitle(fileDialog.getFile());

// 播放器的控制事件處理

player.addControllerListener(this);

// 預讀文件內容

player.prefetch();

}

/**

* 實現(xiàn)ControllerListener接口的方法,處理播放器的控制事件

*/

public void controllerUpdate(ControllerEvent e) {

// 調用player.close()時ControllerClosedEvent事件出現(xiàn)。

// 如果存在視覺部件,則該部件應該拆除(為一致起見,

// 我們對控制面板部件也執(zhí)行同樣的操作)

if (e instanceof ControllerClosedEvent) {

if (vedioComponent != null) {

this.getContentPane().remove(vedioComponent);

this.vedioComponent = null;

}

if (controlComponent != null) {

this.getContentPane().remove(controlComponent);

this.controlComponent = null;

}

return;

}

// 如果是媒體文件到達尾部事件

if (e instanceof EndOfMediaEvent) {

if (loop) {

// 如果允許循環(huán),則重新開始播放

player.setMediaTime(new Time(0));

player.start();

}

return;

}

// 如果是播放器預讀事件

if (e instanceof PrefetchCompleteEvent) {

// 啟動播放器

player.start();

return;

}

// 如果是文件打開完全事件,則顯示視頻組件和控制器組件

if (e instanceof RealizeCompleteEvent) {

vedioComponent = player.getVisualComponent();

if (vedioComponent != null){

this.getContentPane().add(vedioComponent);

}

controlComponent = player.getControlPanelComponent();

if (controlComponent != null){

this.getContentPane().add(controlComponent, BorderLayout.SOUTH);

}

this.pack();

}

}

// 處理“循環(huán)”復選框菜單項的點擊事件

public void itemStateChanged(ItemEvent e) {

loop = !loop;

}

public static void main(String[] args){

new JMFMediaPlayer("JMF媒體播放器");

}

}

試試吧,我這里運行正常

java 折半為什么錯誤?

這個結果沒錯啊,就像你程序中寫的,折半查找算法如果找到了你要找的元素就返回這個元素在這個數(shù)組中的位置,如果沒找到就返回-1,程序中要從arr這個數(shù)組中找元素6,arr這個數(shù)組中沒有6,所以找不到,故返回-1。

用JAVA實現(xiàn)折半插入排序的題目

別忘記給分哦

package com.adtech.interf.test;

public class Test{

public Test(Record a[]) {

int i, j, m, low, high;

Record temp;

for (i = 0; i a.length; i++) {

temp = a[i];

low = 0;

high = i;

while (low = high) {

m = (low + high) / 2;

if (temp.getStudentID() a[m].getStudentID()) {

high = m - 1;

} else {

low = m + 1;

}

}

for (j = i; j high + 1 j 0; j--) { // 如果jhigh 就會少遍歷一個元素 || jlow

a[j] = a[j - 1];

}

a[j] = temp;

}

for (int t = 0; t a.length; t++) {

System.out.println(a[t].getStudentID());

}

}

public static void main(String args[]) {

Record record1 = new Record(2,"張三1",81.0,18);

Record record2 = new Record(4,"張三2",82.0,11);

Record record3 = new Record(5,"張三3",83.0,12);

Record record4 = new Record(43,"張三4",84.0,13);

Record record5 = new Record(21,"張三5",85.0,14);

Record record6 = new Record(54,"張三6",86.0,15);

Record record7 = new Record(22,"張三7",87.0,16);

Record record8 = new Record(6,"張三4",88.0,17);

Record record9 = new Record(223,"張三9",89.0,18);

Record record10 = new Record(545,"張三10",80.0,19);

Record [] record = new Record[]{record1,record2,record3,record4,

record5,record6,record7,record8,record9,record10};

new Test(record);

}

}

java實現(xiàn)折半查找 循環(huán)結束的條件看不懂

二分法查找(折半查找)的時間復雜度是O(log2n)

即是最壞的情況比較次數(shù)是2為底2n的對數(shù)。也就數(shù)如果數(shù)組長度為2,最壞的情況比較2兩次;數(shù)組長度為16,最壞的情況比較5次;數(shù)組長度1204,最壞的情況是比較11次 就可以找到這個值或者確定找不到這個值。

你的代碼就是通過判斷比較的次數(shù)來決定是否結束循環(huán),當已比較(循環(huán))次數(shù)大于最壞情況的次數(shù)還沒有結束(number != a[middle]),則說明數(shù)組中不存在這個值。不過這里是用的N/2來近似的判斷。

另一種更普遍的寫法

public?class?Demo?{

public?static?void?main(String[]?args)?{

//?你原來的代碼

System.out.println(Arrays.toString(a));

Scanner?scanner?=?new?Scanner(System.in);

System.out.println("輸入整數(shù),程序判斷該整數(shù)是否在數(shù)組中:");

int?number?=?scanner.nextInt();

int?index?=?binary(a,?number);

if?(index?==?-1)?{

System.out.printf("%d不在數(shù)組中.\n",?number);

}?else?{

System.out.printf("%d在數(shù)組中,?在數(shù)組中的位置下標是%d.",?number,?index);

}

}

private?static?int?binary(int[]?array,?int?value)?{

int?start?=?0;

int?end?=?array.length?-?1;

while?(start?=?end)?{

int?middle?=?(start?+?end)?/?2;

if?(value?==?array[middle])?{

return?middle;

}?else?if?(value??array[middle])?{

start?=?middle?+?1;

}?else?{

end?=?middle?-?1;

}

}

return?-1;

}

}

網(wǎng)站欄目:java視頻折半代碼 java實現(xiàn)視頻剪輯
URL標題:http://vcdvsql.cn/article48/dopihhp.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄品牌網(wǎng)站設計靜態(tài)網(wǎng)站網(wǎng)站內鏈網(wǎng)站設計公司品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設計公司