对数的操作 开始我的JAVA历程
package Text;
public class Sumn {
public static void main (String args[]){
System.out.println("整数和");
Sum S=new Sum();
S.prient();
System.out.println("偶数和");
sum1 s1=new sum1();
s1.prient();
System.out.println("N!");
sum2 s2=new sum2();
s2.prient();
System.out.println("Fibonacci数列的前N项");
sum3 s3=new sum3();
s3.prient();
}
}
package Text;
public class Sum {
public int sum(int n){
int x=0;
for(int i=1;i<=n;i++){
x=x+i;
}
int s=x;
return s;
}
public void prient(){
System.out.println(sum(100));
}
}
package Text;
public class sum2 {
public int sum(int n){
int x=1;
for(int i=1;i<=n;i++){
x=x*i;
}
int s=x;
return s;
}
public void prient(){
System.out.println(sum(10));
}
}
package Text;
public class sum3 {
int [] intfib=new int[20];
public void prient(){
int i;
int n= 20;
for(i=1;i<=n;i++)
{
if(i==1)
intfib[0]=1;
else if(i==2)
intfib[1]=1;
else intfib[i-1]=intfib[i-2]+intfib[i-3];
System.out.print(intfib[i-1]+" ");
}
}
}
package Text;
public class sum1 {
public int sum(int n){
int x=0;
for(int i=2;i<=n;i+=2){
x=x+i;
}
int s=x;
return s;
}
public void prient(){
System.out.println(sum(100));
}
}
对数的操作 开始我的JAVA历程的更多相关文章
- paip.文件目录操作uAPI php python java对照
paip.文件目录操作uAPI php python java对照 chdir -- 改变目录 chroot -- 改变根目录 dir -- directory 类 closedir -- 关闭目录句 ...
- 基于CDH5.x 下面使用eclipse 操作hive 。使用java通过jdbc连接HIVESERVICE 创建表
基于CDH5.x 下面使用eclipse 操作hive .使用java通过jdbc连接HIVESERVICE 创建表 import java.sql.Connection; import java.s ...
- 危险代码:如何使用Unsafe操作内存中的Java类和对象
危险代码:如何使用Unsafe操作内存中的Java类和对象—Part1 危险代码:如何使用Unsafe操作内存中的Java类和对象—Part2 危险代码:如何使用Unsafe操作内存中的Java类和对 ...
- 最大堆的插入/删除/调整/排序操作(图解+程序)(JAVA)
堆有最大堆和最小堆之分,最大堆就是每个节点的值都>=其左右孩子(如果有的话)值的完全二叉树.最小堆便是每个节点的值都<=其左右孩子值的完全二叉树. 设有n个元素的序列{k1,k2,..., ...
- cassandra高级操作之分页的java实现(有项目具体需求)
接着上篇博客,我们来谈谈java操作cassandra分页,需要注意的是这个分页与我们平时所做的页面分页是不同的,具体有啥不同,大家耐着性子往下看. 上篇博客讲到了cassandra的分页,相信大家会 ...
- HBase操作(Shell与Java API)
版权声明:本文为博主原创文章,未经博主允许不得转载. 转: http://blog.csdn.net/u013980127/article/details/52443155 下面代码在Hado ...
- Java操作Mongodb 保存/读取java对象到/从mongodb
从http://central.maven.org/maven2/org/mongodb/mongo-java-driver/选择一个版本进行下载,这里选择的是3.0.0版本,具体下载以下jar包: ...
- 我的Java历程_写出这个数
lzJava基础进行中,今天偶然间看到的一个题目: 读入一个自然数n,计算其各位数字之和,用汉语拼音写出和的每一位数字.如下代码: import java.util.*;public class Ma ...
- 使用Java操作Elasticsearch(Elasticsearch的java api使用)
1.Elasticsearch是基于Lucene开发的一个分布式全文检索框架,向Elasticsearch中存储和从Elasticsearch中查询,格式是json. 索引index,相当于数据库中的 ...
随机推荐
- 零成本建立的.NET小组开发平台
前言 说道.NET开发平台,首先想到的就是Visual Studio,建立.NET小组开发平台自然首推TFS.但其花费却也是相当昂贵的(当然在本国可以无视这些成本),近期的开发中接触到一些开源软件并读 ...
- javascript每日一练(十)——运动二:缓冲运动
一.缓冲运动 实现原理:(目标距离-当前距离) / 基数 = 速度(运动距离越大速度越小,运动距离和速度成反比) (500 - oDiv.offsetLeft) / 7 = iSpeed; 需要注意: ...
- django-template-loader
当在settings.py中设置了如下 TEMPLATE_LOADERS=( 'django.template.loaders.filesystem.Loader', 'django.template ...
- hdu1198Farm Irrigation (DFS)
Problem Description Benny has a spacious farm land to irrigate. The farm land is a rectangle, and is ...
- MFC:重绘Button,定制CButton,自画CPngButton,求赐教(各种bug包括性能bug)谢谢谢谢
[1.]CPngButton.h(资源是最后图片) #pragma once #include<atlimage.h> #define PNUM 19 #define PLAYTIME 1 ...
- SQL模板和模板实例化
需求:需要得出一个数据源DataTable,我已知SQL和HttpRequest如何,通过SQL模板的方式去实例化匹配HttpRequest中的参数实例化为查询SQL,最后返回DataTable 1. ...
- POJ 1042 Gone Fishing (贪心)(刘汝佳黑书)
Gone Fishing Time Limit: 2000MS Memory Limit: 32768K Total Submissions: 30281 Accepted: 9124 Des ...
- ZOJ 3790 Consecutive Blocks 模拟题
problemCode=3790">Consecutive Blocks 先离散一下,然后模拟,把一种颜色i所在的位置都放入G[i]中.然后枚举一下终点位置,滑动窗体使得起点和终点间花 ...
- adb logcat 命令行用法
作者 :万境绝尘 转载请著名出处 eclipse 自带的 LogCat 工具太垃圾了, 开始用 adb logcat 在终端查看日志; 1. 解析 adb logcat 的帮助信息 在命令行中输入 ...
- HDOJ 1800 Flying to the Mars 盲目搜索......................so easy...........
check the original problem here:http://acm.hdu.edu.cn/showproblem.php?pid=1800 the AC code: #include ...