mirror of
https://github.com/wahyd4/wahyd4.github.com.git
synced 2026-08-09 05:15:56 +10:00
347 lines
18 KiB
HTML
347 lines
18 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-Hans">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width">
|
|
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 6.3.0">
|
|
|
|
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
|
|
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
|
|
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
|
|
<link rel="mask-icon" href="/images/logo.svg" color="#222">
|
|
|
|
<link rel="stylesheet" href="/css/main.css">
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.0/css/all.min.css" integrity="sha256-VHqXKFhhMxcpubYf9xiWdCiojEbY9NexQ4jh8AxbvcM=" crossorigin="anonymous">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
|
|
|
|
<script class="next-config" data-name="main" type="application/json">{"hostname":"toozhao.com","root":"/","images":"/images","scheme":"Muse","darkmode":false,"version":"8.25.0","exturl":false,"sidebar":{"position":"left","width_expanded":320,"width_dual_column":240,"display":"post","padding":18,"offset":12},"hljswrap":true,"codeblock":{"theme":{"light":"default","dark":"stackoverflow-dark"},"prism":{"light":"prism","dark":"prism-dark"},"copy_button":{"enable":false,"style":null},"fold":{"enable":false,"height":500},"language":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"duration":200,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"Searching...","empty":"We didn't find any results for the search: ${query}","hits_time":"${hits} results found in ${time} ms","hits":"${hits} results found"}}</script><script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-theme-next/8.25.0/config.min.js" defer></script>
|
|
|
|
<meta name="description" content="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;刚才正好在看JAVA的双重循环这一块,然后突然就想到了很经典的九九乘法表。因为我们之前C语言里面也写过这样的程序。所以我就试着写这个程序。确实在试的过程中还是发现很多问题和值得注意的地方。下面慢慢说来。 &nbsp;&nbsp;用JAVA写的九九乘法表。 **&nbsp;&nbs">
|
|
<meta property="og:type" content="article">
|
|
<meta property="og:title" content="Java双重循环的典型应用(九九乘法表)">
|
|
<meta property="og:url" content="https://toozhao.com/2010/02/03/Java%E5%8F%8C%E9%87%8D%E5%BE%AA%E7%8E%AF%E7%9A%84%E5%85%B8%E5%9E%8B%E5%BA%94%E7%94%A8%EF%BC%88%E4%B9%9D%E4%B9%9D%E4%B9%98%E6%B3%95%E8%A1%A8%EF%BC%89/index.html">
|
|
<meta property="og:site_name" content="大染志">
|
|
<meta property="og:description" content="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;刚才正好在看JAVA的双重循环这一块,然后突然就想到了很经典的九九乘法表。因为我们之前C语言里面也写过这样的程序。所以我就试着写这个程序。确实在试的过程中还是发现很多问题和值得注意的地方。下面慢慢说来。 &nbsp;&nbsp;用JAVA写的九九乘法表。 **&nbsp;&nbs">
|
|
<meta property="og:locale">
|
|
<meta property="og:image" content="http://img.bimg.126.net/photo/Qq_PXIya9rduD-DBLMyd_Q==/5671720780721238163.jpg">
|
|
<meta property="og:image" content="http://img.bimg.126.net/photo/APft0EoQVcSefNmqxzr9kw==/5671720780721238166.jpg">
|
|
<meta property="article:published_time" content="2010-02-03T00:02:38.000Z">
|
|
<meta property="article:modified_time" content="2025-10-27T10:42:00.765Z">
|
|
<meta property="article:author" content="Junv">
|
|
<meta name="twitter:card" content="summary">
|
|
<meta name="twitter:image" content="http://img.bimg.126.net/photo/Qq_PXIya9rduD-DBLMyd_Q==/5671720780721238163.jpg">
|
|
|
|
|
|
<link rel="canonical" href="https://toozhao.com/2010/02/03/Java%E5%8F%8C%E9%87%8D%E5%BE%AA%E7%8E%AF%E7%9A%84%E5%85%B8%E5%9E%8B%E5%BA%94%E7%94%A8%EF%BC%88%E4%B9%9D%E4%B9%9D%E4%B9%98%E6%B3%95%E8%A1%A8%EF%BC%89/">
|
|
|
|
|
|
<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-Hans","comments":true,"permalink":"https://toozhao.com/2010/02/03/Java%E5%8F%8C%E9%87%8D%E5%BE%AA%E7%8E%AF%E7%9A%84%E5%85%B8%E5%9E%8B%E5%BA%94%E7%94%A8%EF%BC%88%E4%B9%9D%E4%B9%9D%E4%B9%98%E6%B3%95%E8%A1%A8%EF%BC%89/","path":"2010/02/03/Java双重循环的典型应用(九九乘法表)/","title":"Java双重循环的典型应用(九九乘法表)"}</script>
|
|
|
|
<script class="next-config" data-name="calendar" type="application/json">""</script>
|
|
<title>Java双重循环的典型应用(九九乘法表) | 大染志</title>
|
|
|
|
<script async src="https://www.googletagmanager.com/gtag/js?id=G-7N71TMKK99"></script>
|
|
<script class="next-config" data-name="google_analytics" type="application/json">{"tracking_id":"G-7N71TMKK99","only_pageview":false,"measure_protocol_api_secret":null}</script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-theme-next/8.25.0/third-party/analytics/google-analytics.min.js" defer></script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous" defer></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-theme-next/8.25.0/utils.min.js" defer></script><script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-theme-next/8.25.0/motion.min.js" defer></script><script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-theme-next/8.25.0/sidebar.min.js" defer></script><script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-theme-next/8.25.0/next-boot.min.js" defer></script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<noscript>
|
|
<link rel="stylesheet" href="/css/noscript.css">
|
|
</noscript>
|
|
</head>
|
|
|
|
<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
|
|
<div class="headband"></div>
|
|
|
|
<main class="main">
|
|
<div class="column">
|
|
<header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
|
|
<div class="site-nav-toggle">
|
|
<div class="toggle" aria-label="Toggle navigation bar" role="button">
|
|
<span class="toggle-line"></span>
|
|
<span class="toggle-line"></span>
|
|
<span class="toggle-line"></span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="site-meta">
|
|
|
|
<a href="/" class="brand" rel="start">
|
|
<i class="logo-line"></i>
|
|
<p class="site-title">大染志</p>
|
|
<i class="logo-line"></i>
|
|
</a>
|
|
<p class="site-subtitle" itemprop="description">想要玩得很 High 的程序员</p>
|
|
</div>
|
|
|
|
<div class="site-nav-right">
|
|
<div class="toggle popup-trigger" aria-label="Search" role="button">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<nav class="site-nav">
|
|
<ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>Home</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>About</a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>Archives<span class="badge">308</span></a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>Tags<span class="badge">249</span></a></li><li class="menu-item menu-item-知识图谱"><a href="https://wiki.toozhao.com/" rel="section" target="_blank"><i class="fa fa-sitemap fa-fw"></i>知识图谱</a></li>
|
|
</ul>
|
|
</nav>
|
|
|
|
|
|
|
|
|
|
</header>
|
|
|
|
|
|
<aside class="sidebar">
|
|
|
|
<div class="sidebar-inner sidebar-overview-active">
|
|
<ul class="sidebar-nav">
|
|
<li class="sidebar-nav-toc">
|
|
Table of Contents
|
|
</li>
|
|
<li class="sidebar-nav-overview">
|
|
Overview
|
|
</li>
|
|
</ul>
|
|
|
|
<div class="sidebar-panel-container">
|
|
<!--noindex-->
|
|
<div class="post-toc-wrap sidebar-panel">
|
|
</div>
|
|
<!--/noindex-->
|
|
|
|
<div class="site-overview-wrap sidebar-panel">
|
|
<div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
|
|
<p class="site-author-name" itemprop="name">Junv</p>
|
|
<div class="site-description" itemprop="description">Go, JavaScript, Ruby on Rails, Java,Docker, CI, CD, Photography</div>
|
|
</div>
|
|
<div class="site-state-wrap animated">
|
|
<nav class="site-state">
|
|
<div class="site-state-item site-state-posts">
|
|
<a href="/archives/">
|
|
<span class="site-state-item-count">308</span>
|
|
<span class="site-state-item-name">posts</span>
|
|
</a>
|
|
</div>
|
|
<div class="site-state-item site-state-categories">
|
|
<a href="/categories/">
|
|
<span class="site-state-item-count">69</span>
|
|
<span class="site-state-item-name">categories</span></a>
|
|
</div>
|
|
<div class="site-state-item site-state-tags">
|
|
<a href="/tags/">
|
|
<span class="site-state-item-count">249</span>
|
|
<span class="site-state-item-name">tags</span></a>
|
|
</div>
|
|
</nav>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</aside>
|
|
|
|
|
|
</div>
|
|
|
|
<div class="main-inner post posts-expand">
|
|
|
|
|
|
|
|
|
|
|
|
<div class="post-block">
|
|
|
|
|
|
|
|
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-Hans">
|
|
<link itemprop="mainEntityOfPage" href="https://toozhao.com/2010/02/03/Java%E5%8F%8C%E9%87%8D%E5%BE%AA%E7%8E%AF%E7%9A%84%E5%85%B8%E5%9E%8B%E5%BA%94%E7%94%A8%EF%BC%88%E4%B9%9D%E4%B9%9D%E4%B9%98%E6%B3%95%E8%A1%A8%EF%BC%89/">
|
|
|
|
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
|
|
<meta itemprop="image" content="/images/avatar.gif">
|
|
<meta itemprop="name" content="Junv">
|
|
</span>
|
|
|
|
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
|
|
<meta itemprop="name" content="大染志">
|
|
<meta itemprop="description" content="Go, JavaScript, Ruby on Rails, Java,Docker, CI, CD, Photography">
|
|
</span>
|
|
|
|
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
|
|
<meta itemprop="name" content="Java双重循环的典型应用(九九乘法表) | 大染志">
|
|
<meta itemprop="description" content="">
|
|
</span>
|
|
<header class="post-header">
|
|
<h1 class="post-title" itemprop="name headline">
|
|
Java双重循环的典型应用(九九乘法表)
|
|
</h1>
|
|
|
|
<div class="post-meta-container">
|
|
<div class="post-meta">
|
|
<span class="post-meta-item">
|
|
<span class="post-meta-item-icon">
|
|
<i class="far fa-calendar"></i>
|
|
</span>
|
|
<span class="post-meta-item-text">Posted on</span>
|
|
|
|
<time title="Created: 2010-02-03 11:02:38" itemprop="dateCreated datePublished" datetime="2010-02-03T11:02:38+11:00">2010-02-03</time>
|
|
</span>
|
|
<span class="post-meta-item">
|
|
<span class="post-meta-item-icon">
|
|
<i class="far fa-calendar-check"></i>
|
|
</span>
|
|
<span class="post-meta-item-text">Edited on</span>
|
|
<time title="Modified: 2025-10-27 21:42:00" itemprop="dateModified" datetime="2025-10-27T21:42:00+11:00">2025-10-27</time>
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</header>
|
|
|
|
|
|
|
|
|
|
<div class="post-body" itemprop="articleBody"><p> 刚才正好在看JAVA的双重循环这一块,然后突然就想到了很经典的九九乘法表。因为我们之前C语言里面也写过这样的程序。所以我就试着写这个程序。确实在试的过程中还是发现很多问题和值得注意的地方。下面慢慢说来。</p>
|
|
<p> 用JAVA写的九九乘法表。</p>
|
|
<p><font COLOR="#0000FF" STYLE="line-height:1.3em;">**<wbr /> public class new4 </p>
|
|
<p>{</p>
|
|
<p> public static void main(String[] args) </p>
|
|
<p> {</p>
|
|
<p> int a,b,s;</p>
|
|
<p> for (a=1;a<=9 ;a++ )</p>
|
|
<p> {</p>
|
|
<p> for(b=1;b<=a;b++)</p>
|
|
<p> {</p>
|
|
<p> s=a*b;</p>
|
|
<p> System.out.print(a+”*”+b+”=”+s);</p>
|
|
<p> System.out.print(“ ”);</p>
|
|
<p> }</p>
|
|
<p> System.out.println();</p>
|
|
<p> }</p>
|
|
<p> </p>
|
|
<p> }</p>
|
|
<p>}<br>**<wbr /></FONT><wbr /><font COLOR="#000000" STYLE="line-height:1.3em;">用C语言写的九九乘法表</FONT><wbr /></p>
|
|
<p>**<wbr /><font COLOR="#0000FF" STYLE="line-height:1.3em;">#include ”stdio.h” //九九乘法表。</p>
|
|
<p>void main()</p>
|
|
<p>{</p>
|
|
<p> int i,j,s;</p>
|
|
<p> for (i=1;i<=9;i++)</p>
|
|
<p> {</p>
|
|
<p> for(j=1;j<=i;j++)</p>
|
|
<p> { s=i*j;</p>
|
|
<p> printf (“%d*%d=%-4d”,i,j,s);</p>
|
|
<p> }</p>
|
|
<p> printf (“\n”) ;</p>
|
|
<p> }</p>
|
|
<p> </p>
|
|
<p>}</FONT><wbr />**<wbr /></p>
|
|
<p> <wbr /><img src="http://img.bimg.126.net/photo/Qq_PXIya9rduD-DBLMyd_Q==/5671720780721238163.jpg" alt="Java双重循环的典型应用(九九乘法表) - wahyd4 - 龙的博客" title="Java双重循环的典型应用(九九乘法表) - wahyd4 - 龙的博客"><wbr />这个是没用使用空格</p>
|
|
<p><wbr /><img src="http://img.bimg.126.net/photo/APft0EoQVcSefNmqxzr9kw==/5671720780721238166.jpg" alt="Java双重循环的典型应用(九九乘法表) - wahyd4 - 龙的博客" title="Java双重循环的典型应用(九九乘法表) - wahyd4 - 龙的博客"><wbr />这个是使用了空格,但是没有左对齐。</p>
|
|
<p><font COLOR="#0000FF" STYLE="line-height:1.3em;"><strong><wbr /> <font COLOR="#000000" STYLE="line-height:1.3em;">其实通过比较我们就可以很容易看到,这个 程序JAVA和C的代码都是差不多的。只是细节上有一些变化。有个不同就是我不不知道JAVA里面有没有类似</FONT><wbr /></strong><wbr /><font COLOR="#0000FF" STYLE="line-height:1.3em;"><em><em><wbr /> printf (“%d</em>%d=%-4d”,i,j,s);这样的语句。即实现左对齐。</em>*<wbr /></FONT><wbr /></FONT><wbr /><font COLOR="#000000" STYLE="line-height:1.3em;">于是我在JAVA里面想到了这样一个办法。再输出一行,让它打印空格就好。</FONT><wbr /></p>
|
|
<p> **<wbr /><font COLOR="#0000FF" STYLE="line-height:1.3em;"> System.out.print(a+”*”+b+”=”+s);</p>
|
|
<p> System.out.print(“ ”);</FONT><wbr />**<wbr /></p>
|
|
<p> <strong><wbr /><font COLOR="#0000FF" STYLE="line-height:1.3em;">当然我也试过这样一种方法。即System.out.print(a+”*”+b+”=”+s “ ”)但是通过编译发现这样是行不通的。</FONT><wbr /></strong><wbr /></p>
|
|
<p><strong><wbr /><font COLOR="#0000FF" STYLE="line-height:1.3em;"> 还有一个就是我晓得了那个String ()agrs .它其实就是一个数组其实相当于是程序比不可少的东西,不管怎样你都要写出来,但是你还是可以选择不在程序里面使用它。</FONT><wbr /></strong><wbr /><br>.</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<footer class="post-footer">
|
|
|
|
|
|
|
|
<div class="post-nav">
|
|
<div class="post-nav-item">
|
|
<a href="/2010/02/02/JAVA%E9%87%8C%E9%9D%A2%E9%87%8D%E8%A6%81%E8%80%8C%E5%9F%BA%E7%A1%80%E7%9A%84%E4%B8%9C%E8%A5%BF/" rel="prev" title="JAVA里面重要而基础的东西">
|
|
<i class="fa fa-angle-left"></i> JAVA里面重要而基础的东西
|
|
</a>
|
|
</div>
|
|
<div class="post-nav-item">
|
|
<a href="/2010/02/04/You%E6%88%91%E5%8F%8B%EF%BC%8C%E5%90%BE%E6%9C%89%E4%BE%BF%E6%97%A0%E5%BF%A7/" rel="next" title="You我友,吾有便无忧">
|
|
You我友,吾有便无忧 <i class="fa fa-angle-right"></i>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
</article>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
</main>
|
|
|
|
<footer class="footer">
|
|
<div class="footer-inner">
|
|
|
|
<div class="copyright">
|
|
©
|
|
<span itemprop="copyrightYear">2025</span>
|
|
<span class="with-love">
|
|
<i class="fa fa-heart"></i>
|
|
</span>
|
|
<span class="author" itemprop="copyrightHolder">Junv</span>
|
|
</div>
|
|
<div class="powered-by">Powered by <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/muse/" rel="noopener" target="_blank">NexT.Muse</a>
|
|
</div>
|
|
|
|
</div>
|
|
</footer>
|
|
|
|
|
|
<div class="toggle sidebar-toggle" role="button">
|
|
<span class="toggle-line"></span>
|
|
<span class="toggle-line"></span>
|
|
<span class="toggle-line"></span>
|
|
</div>
|
|
<div class="sidebar-dimmer"></div>
|
|
<div class="back-to-top" role="button" aria-label="Back to top">
|
|
<i class="fa fa-arrow-up fa-lg"></i>
|
|
<span>0%</span>
|
|
</div>
|
|
<div class="reading-progress-bar"></div>
|
|
|
|
<noscript>
|
|
<div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
|
|
</noscript>
|
|
|
|
</body>
|
|
</html>
|