import java.util.Scanner;
public class star{
public static void main(String[] args){
System.out.println("请输入要打印的星星的行数");
Scanner input = new Scanner(System.in);
int num = input.nextInt();
printTriangle(num);
}
public static void printTriangle(int line){
for(int i=1;i<=line;i++){
for(int j=i;j<line;j++){
System.out.print(" ");
}
for(int j=1;j<=i*2-1;j++){
System.out.print("*");
}
System.out.println();
}
}
}
相关推荐
viple进阶4:打印空心三角形
viple,空心三角形
2021-10-24求救大神计算机思维
大神救命,viple做星号作业:用参数传递方式循环完成下面的图形显示(行数通过参数控制,输入 10则最后一行是 9 个星号,输入 100 则最后一行是 99 个星号,即实际参数在 main 活动中输入
viple进阶1:打印星号
viple,打印星号
使用JAVA画菱形,可以采用传参的方式灵活画出菱形---新手!
灵活使用JAVA画菱形 package JiChuLianxi; /** 灵活画菱形 啊哈哈哈哈 @author Administrator */ public class Lianxi33 { public void doit(int a ) { //上半部分 for (int i = 1; i <= a; i++) { //控制行数 //画空格 ...
VIPLE实现打印等腰三角形
VIPLE实现打印等腰三角形,使用变量、循环、自定义活动、参数传递等知识,实现打印等腰三角形。其核心思想是:打印N个空格和打印N个星号可以合并为一个自定义活动,逻辑相同,仅仅是图形不同,可以进行合并。算法核心是:打印一行,先计算出打印的空格数,再拼接上打印的星号数,从而实现打印效果,详情请阅读源码,如有不清楚可以联系作者。
用数组输出星星的问题,当读入行数时,则输入几行后就可输出第一行有一个星,第二行有两个,第n行有n个星,
用数组输出星星的问题,当读入行数时,则输入几行后就可输出第一行有一个星,第二行有两个,第n行有n个星。
C语言练习-main函数的参数和打印杨辉三角
代码实现效果是: 在执行文件时 传入main函数的参数为1 打印三角 传入main函数的参数为1 1 打印菱形 传入main函数的参数为1 1 1 打印字母三角 传入main函数的参数为1 1 1 1打印字母菱形 代码如下 //只是我的兴趣,并无其它! #include<stdio.h> #include<stdlib.h> void xin(int argc,char** argv); //打印星星 void Char(int argc,char**
工程经验分享:PCIE(1)
本文介绍AXI Bridge For Pcie Express Gen3 Subsystem 的使用方法。这个IP兼具简单与实用性,将PCIE协议层实现于内部,仅留出AXI接口供开发者使用。开发者不需要处理复杂的PCIE协议数据,只需要对AXI总线有所了解即可,十分符合Xilinx一贯的开发风格。本文无关PCIE协议本身,仅分享实用性的工程经验,以PCIE IP为核心,一步一步搭建一个简单的子系统,以此说明用法。文中所有内容均已通过项目检验。
C | 输出一个n行m列矩形方阵 发现的几个问题
C语言 | 输出n行*m列的矩形方阵 | 超级啰嗦的菜鸡版本
Frida实战:高效dump Android内存中的so文件与修复技巧
本文详细介绍了使用Frida工具dump Android内存中已解密so文件的实战技巧。针对加固应用静态分析失效的痛点,文章提供了从环境搭建、使用frida_dump脚本自动化抓取内存数据,到利用SoFixer工具修复ELF文件结构的完整流程,帮助逆向分析人员高效获取可分析的so文件。
SAP Business One自定义表与字段实战:从零构建企业专属数据模型
本文详细介绍了如何在SAP Business One中创建自定义表与字段,从零构建企业专属数据模型。通过实战案例和避坑指南,帮助用户掌握业务适配、流程优化和权限隔离等关键技巧,提升系统灵活性和数据管理效率。特别适合需要扩展标准功能的SAP Business One用户。
JavaScript 基础入门(day4):吃透函数核心,从封装到作用域!
函数的核心是封装复用,通过 “声明 - 调用” 实现重复逻辑的高效管理。参数让函数更灵活,返回值让函数结果可复用,两者结合能实现 “输入 - 处理 - 输出” 的完整逻辑。作用域解决了变量名冲突问题,局部变量优先于全局变量,开发中尽量少用全局变量。匿名函数和立即执行函数是常用的进阶形式,适合特定场景(比如赋值、一次性执行)。通过这篇笔记,建议你多写几个实例练习:比如用函数实现 “计算圆的面积”“判断一个数是否为质数”,既能巩固知识点,又能理解函数在实际开发中的用法。要不要我帮你整理一份。
逆向淘宝x-mini-wua:从加密算法到设备指纹的生成逻辑
本文深入剖析了淘宝风控核心参数x-mini-wua的生成逻辑与加密算法。通过逆向分析,揭示了其作为设备“身份证”的作用,详细拆解了从硬件信息采集、SG_INNER_DATA文件解密、关键参数提取到最终长wua合成的完整技术链条,并探讨了模拟生成与绕过风控的实战思路及注意事项。
Python之基础函数案例详解
需要注意的是, 在有些语言中, 函数的调用可以发生在函数的定义之前, 而Python中, 函数的调用只能在函数的蒂尼之后, 如果在函数定义前就调用函数, Python会找不到函数, 从而报错。创建一个 九九乘法表.py文件, 文件内定义一个函数 priint_99(), 函数内是打印九九乘法表的代码。接下来创建一个 函数.py文件, 在文件中导入 九九乘法表文件(通常叫做模块), 而后调用模块中的函数。运行 函数.py文件, 即可调函数中的代码, 从而打印出九九乘法表的内容。
手把手教你学PCIE--所有 PF(Physical Function)共同管理和分配 VF
但具体如何分配和使用 VF 取决于硬件设计、驱动程序配置以及实际应用场景。
肖特基二极管的反向恢复过程
本博客简述肖特基二极管反向恢复过程。
两个小时摆脱Java小白--方法详解
1、方法的定义 为什么要有方法? 方法(又叫函数)就是一段特定功能的代码块。方法提高程序的复用性和可读性。 比如,有了方法,我们可以把要重复使用的一段代码提炼出来,然后在每个需要执行这段代码的地方去调用即可。 打过飞机吗?(emmm…) 在一个打飞机的游戏中,飞机需要发射子弹,那么我们可以把发射子弹的这段代码写成方法,这样就可以避免每次重写相同的代码。 方法的格式 语法: 访问权限修饰符 [其他的...
【LAMMPS学习】八、基础知识(4.5)TIP5P水模型
五点 TIP5P 刚性水模型通过添加两个通常无质量的附加位点 L 来扩展three-point TIP3P model,其中放置与氧原子相关的电荷。这些位点 L 位于距氧原子固定距离处,形成从 HOH 平面旋转 90 度的四面角。因此,这些位点在某种程度上近似于氧的孤对,从而改善了水结构,与four-point TIP4P model相比变得更加“四面体”。
Java--方法
一、方法的定义 (1)方法定义: 方法,又叫函数,就是一段特定功能的代码块。方法可以提高程序的复用性和可读性。在未调用时,方法是不会运行的。 (2)语法格式: 访问权限修饰符 其他修饰符 返回值类型 方法名(参数类型 形参1, 参数类型 形参2,..){ 方法体; return 返回值; } public 访问权限修饰符 static 静态修饰符,描述的方法可以直接调用 void 返回值类型(无返回值) 二、方法的形...
图解联合概率密度、边缘概率密度、条件概率密度之间的关系
简要图解联合概率密度、边缘概率密度、条件概率密度之间的关系
蓝牙模块HM-10手册
蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。
java中方法的定义
方法的定义
efm32 入门.pdf
本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。
快速浏览 js的ECMAScript语法基础
js的ECMAScript语法基础
TMS_WebGMaps_1.9.8.0_Full_Source
TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
WEB Basic基础-10
1900年1月1日是星期一1900年1月30日是星期二2018年6月12日year:2018month:6day:12从 1900年 开始 到 year-1年 整年相加从year年 1月 到 month-1月 整月相加再加day日 一 二 三 四 五 六 1 2 3 4 5 6 7 8 910 =============================...
实验五 循环结构程序设计
1.最大公约数和最小公倍数【X】5.2提高实验任务【X】3.百钱白鸡问题【X】
[学习笔记] 方法与数组_方法的定义与参数
方法(又叫函数)就是一段特定功能的代码块。方法提高程序的复用性和可读性。在调用方法中,如果我们定义的方法有参数,就必须在调用方法的同时传入这个值,即给当前方法中的参数赋值,比如,有了方法,我们可以把要重复使用的一段代码提炼出来,然后在每个需要执行这段代码的地方去调用即可。、实参和形参的类型要相互兼容,且:实参的取值范围要小于或者等于形参类型的取值范围。 小结:形参就是一个变量,实参就是一个值,传参就是把一个值给一个形参赋值。就是方法定义上的,用于接收实际参数的。
449



被折叠的 条评论
为什么被折叠?



