iiishooter's Blog - Attitude is Altitude

去除整形数组中为0的元素

将整形数组中为0的元素去掉,并将剩余的元素复制到一个新的数组中并输出。

public class Move0 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int array1[]={0,1,2,3,4,0,0,5,6,0,7,8,9,10,11,0};  //初始化数组1
		int flag=0;
		for(int i=0;i<array1.length;i++)        //求出数组2的长度
		if(array1[i]!=0)
		{
			flag++;
		}
		int array2 [] =new int [flag];       //定义数组2

继续阅读

计算1!+2!+...+30!

主要考虑两个问题:

1.数字长度溢出

2.BigInteger类的使用

 

代码如下

import java.math.BigInteger;
public class jiecheng {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int array [] = new int [30];
		BigInteger sum =new BigInteger(String.valueOf(0));

继续阅读

Ubuntu几个国内的source

#Ubuntu 10.04 台湾更新源:

deb http://tw.archive.ubuntu.com/ubuntu/ lucid main universe restricted multiverse
deb http://tw.archive.ubuntu.com/ubuntu/ lucid-updates universe main multiverse restricted
deb http://tw.archive.ubuntu.com/ubuntu/ lucid-proposed universe main multiverse restricted
deb http://tw.archive.ubuntu.com/ubuntu/ lucid-security universe main multiverse restricted
deb http://tw.archive.ubuntu.com/ubuntu/ lucid-backports main multiverse restricted universe
deb-src http://tw.archive.ubuntu.com/ubuntu/ lucid main universe restricted multiverse
deb-src http://tw.archive.ubuntu.com/ubuntu/ lucid-security universe main multiverse restricted
deb-src http://tw.archive.ubuntu.com/ubuntu/ lucid-updates universe main multiverse restricted
deb-src http://tw.archive.ubuntu.com/ubuntu/ lucid-proposed universe main multiverse restricted
deb-src http://tw.archive.ubuntu.com/ubuntu/ lucid-backports universe main multiverse restricted

继续阅读

Ubuntu 与 Windows双系统分区挂载

简单介绍

1.硬盘分区表示方法

/dev/hda hdahd表示dard diskIDE接口; a表示硬盘号

/dev/sda sdasd表示SCSI dskIDE以外接口的硬盘

例:/dev/sdb1表示SCSI接口的第二快硬盘上的第一个分区

注意:kernel 2.6.19之后已经都使用/dev/sdx来表示了。

grub中所有硬盘都用hdx表示,x0开始。(hd11)表示地2块硬盘 的第二个分区。

2. /etc/fstab介绍

格式:

设备名        挂载点        格式          挂载选项         是否备份      检查顺序

 /dev/sdx      /home             ext4             defaults                  0                    2

 

继续阅读

Ubuntu 学习(附1)——The description of the ubuntu file system

Its from www.ubuntu.org

1

DESCRIPTION

A typical Linux system has, among others, the following directories:

 

/ This is the root directory. This is where the whole tree starts.

/bin This directory contains executable programs which are needed in single user mode and to bring the system up or repair it.

/boot Contains static files for the boot loader. This directory only holds the files which are needed during the boot process. The map installer and configuration files should go to /sbin and /etc.

/dev Special or device files,which refer to physical devices.See mknod(1).

/etc Contains configuration files which are local to the machine.Some larger software packages, like X11, can have their own subdirectories below /etc. Site-wide configuration files may be placed here or in /usr/etc. Nevertheless, programs should always look for these files in /etc and you may have links for these files to /usr/etc.

/etc/opt

Host-specific configuration files for add-on applications installed in /opt.

继续阅读

Ubuntu 学习6——GUN编译环境

6. GNU 编译环境

6.1 GNU编译器

GNU编译器用于将源程序编译为中间语言,之后再对中间语言进行第二次编译,生成机器码。编译默认输出的文件为源代码所在位置的目录的.a/out

6.1.1 gcc,g++

c语言编译过程:预编译编译汇编连接

gcc [参数] [源程序]

g++ [参数] [源程序]

参数:

-g:增加调试信息

-c:只编译和汇编,不连接

-S:只编译,不汇编

-E:只预编译

-o file:指定输出文件

-v:打印编译的命令。

 

继续阅读

Ubuntu 学习5——系统核心配置文件(未完成)

5. 系统核心配置文件

5.1 /etc/passwd

5.2 /etc/fstab

5.3 /etc/apt/sources.list

 

待续... ...

Ubuntu 学习4——Ubuntu包管理

4. Ubuntu包管理

4.1 apt-***软件套装和aptitude

4.2.1 apt-get

apt:advanced package tools

apt-get [参数] [包的名称]

参数:

install:安装新的包。先下载到硬盘,再安装。如果缓冲存储中存在该包则直接安装

remove:卸载。配置文件将保留,以便下次安装。

autoremove:删除系统没有用到的包

clean:删除硬盘里面的缓冲存储的包(默认位置:/var/cache/apt/archives

autoclean:删除缓冲存储里面旧版本的包

source:下载源码

update:下载更新软件包列表

upgrade:升级系统

dist-upgrade:发布版升级

check:检查系统完整性

继续阅读

Ubuntu 学习3——管理命令

3. 管理命令

3.1 帐号控制

3.1.1 su

作用:改变当前登录用户

su [参数] [用户名称]

参数:

-C command:登录之后运行命令command

-s Shell:选择登录之后用的shell

提示:不输入任何参数就改变为root

 

3.1.2 sudo

作用:第一普通用户升级root用户。

sudo [命令]

继续阅读

Ubuntu 学习2——常用命令

2. 常用命令

2.1 公共部分

2.1.1 参数

几乎所有命令都有的几个参数:

--help 帮助

--version 显示版本

以“-”开头的参数是单字母参数,以“--”开头的参数是多字母参数。如果多个单字母参数后没有其他参数,则可以折叠。参数区分大小写。

2.1.2 文件名

Linux支持长文件名,如果问加命中有空格则在使用此文件名的时候应在文件名上加双引号,或在空格前加\

如:cd “Charles zhang”,cd Charles\ zhang

2.1.3 多重文件输入

很多命令后可以跟多个文件名,程序将自动依次处理。如:ls -l a b c,此命令将以此列举三个文件夹的信息。

 

继续阅读




Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee