亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? chapter1.html

?? C programming language. An excellent book on C programming. Recommended to C beginner.
?? HTML
?? 第 1 頁 / 共 5 頁
字號:
a program looks, proper indentation and spacing are critical in makingprograms easy for people to read. We recommend writing only one statement perline, and using blanks around operators to clarify grouping. The position ofbraces is less important, although people hold passionate beliefs. We havechosen one of several popular styles. Pick a style that suits you, then useit consistently.<p>Most of the work gets done in the body of the loop. The Celsius temperatureis computed and assigned to the variable <tt>celsius</tt> by the statement<pre>        celsius = 5 * (fahr-32) / 9;</pre>The reason for multiplying by 5 and dividing by 9 instead of just multiplyingby <tt>5/9</tt> is that in C, as in many other languages, integer division<em> truncates</em>: any fractional part is discarded. Since <tt>5</tt> and<tt>9</tt> are integers. <tt>5/9</tt> would be truncated to zero and so allthe Celsius temperatures would be reported as zero.<p>This example also shows a bit more of how <tt>printf</tt> works. <tt>printf</tt>is a general-purpose output formatting function, which we will describe indetail in <a href="chapter7.html">Chapter 7</a>. Its first argument is a stringof characters to be printed, with each <tt>%</tt> indicating where one of theother (second, third, ...) arguments is to be substituted, and in what formit is to be printed. For instance, <tt>%d</tt> specifies an integer argument,so the statement<pre>        printf("%d\t%d\n", fahr, celsius);</pre>causes the values of the two integers <tt>fahr</tt> and <tt>celsius</tt> to beprinted, with a tab (<tt>\t</tt>) between them.<p>Each <tt>%</tt> construction in the first argument of <tt>printf</tt> is pairedwith the corresponding second argument, third argument, etc.; they must matchup properly by number and type, or you will get wrong answers.<p>By the way, <tt>printf</tt> is not part of the C language; there is no input oroutput defined in C itself. <tt>printf</tt> is just a useful function from thestandard library of functions that are normally accessible to C programs. Thebehaviour of <tt>printf</tt> is defined in the ANSI standard, however, so itsproperties should be the same with any compiler and library that conforms tothe standard.<p>In order to concentrate on C itself, we don't talk much about input andoutput until <a href="chapter7.html">chapter 7</a>. In particular, we willdefer formatted input until then. If you have to input numbers, read thediscussion of the function <tt>scanf</tt> in<a href="chapter7.html#s7.4">Section 7.4</a>. <tt>scanf</tt> is like<tt>printf</tt>, except that it reads input instead of writing output.<p>There are a couple of problems with the temperature conversion program. Thesimpler one is that the output isn't very pretty because the numbers are notright-justified. That's easy to fix; if we augment each <tt>%d</tt> in the<tt>printf</tt> statement with a width, the numbers printed will be right-justifiedin their fields. For instance, we might say<pre>   printf("%3d %6d\n", fahr, celsius);</pre>to print the first number of each line in a field three digits wide, and thesecond in a field six digits wide, like this:<pre>     0     -17    20      -6    40       4    60      15    80      26   100      37   ...</pre>The more serious problem is that because we have used integer arithmetic, theCelsius temperatures are not very accurate; for instance, 0<sup>o</sup>F isactually about -17.8<sup>o</sup>C, not -17. To get more accurate answers, weshould use floating-point arithmetic instead of integer. This requires somechanges in the program. Here is the second version:<pre>   #include &lt;stdio.h&gt;   /* print Fahrenheit-Celsius table       for fahr = 0, 20, ..., 300; floating-point version */   main()   {     float fahr, celsius;     float lower, upper, step;     lower = 0;      /* lower limit of temperatuire scale */     upper = 300;    /* upper limit */     step = 20;      /* step size */     fahr = lower;     while (fahr &lt;= upper) {         celsius = (5.0/9.0) * (fahr-32.0);         printf("%3.0f %6.1f\n", fahr, celsius);         fahr = fahr + step;     }   }</pre>This is much the same as before, except that <tt>fahr</tt> and <tt>celsius</tt>are declared to be <tt>float</tt> and the formula for conversion is written in amore natural way. We were unable to use <tt>5/9</tt> in the previous versionbecause integer division would truncate it to zero. A decimal point in aconstant indicates that it is floating point, however, so <tt>5.0/9.0</tt> isnot truncated because it is the ratio of two floating-point values.<p>If an arithmetic operator has integer operands, an integer operation isperformed. If an arithmetic operator has one floating-point operand and oneinteger operand, however, the integer will be converted to floating pointbefore the operation is done. If we had written <tt>(fahr-32)</tt>, the <tt>32</tt>would be automatically converted to floating point. Nevertheless, writingfloating-point constants with explicit decimal points even when they haveintegral values emphasizes their floating-point nature for human readers.<p>The detailed rules for when integers are converted to floating point are in<a href="chapter2.html">Chapter 2</a>. For now, notice that the assignment<pre>   fahr = lower;</pre>and the test<pre>   while (fahr &lt;= upper)</pre>also work in the natural way - the <tt>int</tt> is converted to <tt>float</tt>before the operation is done.<p>The <tt>printf</tt> conversion specification <tt>%3.0f</tt> says that afloating-point number (here <tt>fahr</tt>) is to be printed at least threecharacters wide, with no decimal point and no fraction digits. <tt>%6.1f</tt>describes another number (<tt>celsius</tt>) that is to be printed at least sixcharacters wide, with 1 digit after the decimal point. The output looks likethis:<pre>     0   -17.8    20    -6.7    40     4.4   ...</pre>Width and precision may be omitted from a specification: <tt>%6f</tt> says thatthe number is to be at least six characters wide; <tt>%.2f</tt> specifies twocharacters after the decimal point, but the width is not constrained; and<tt>%f</tt> merely says to print the number as floating point.<p><table align="center" border=1><td>&nbsp;<tt>%d</tt>   </td><td>&nbsp;print as decimal integer</td><tr><td>&nbsp;<tt>%6d</tt>  </td><td>&nbsp;print as decimal integer, at least 6 characters wide</td><tr><td>&nbsp;<tt>%f</tt>   </td><td>&nbsp;print as floating point</td><tr><td>&nbsp;<tt>%6f</tt>  </td><td>&nbsp;print as floating point, at least 6 characters wide</td><tr><td>&nbsp;<tt>%.2f</tt> </td><td>&nbsp;print as floating point, 2 characters after decimal point</td><tr><td>&nbsp;<tt>%6.2f</tt>&nbsp;&nbsp;</td><td>&nbsp;print as floating point, at least 6 wide and 2 after decimal point&nbsp;</td></table><p>Among others, <tt>printf</tt> also recognizes <tt>%o</tt> for octal, <tt>%x</tt>for hexadecimal, <tt>%c</tt> for character, <tt>%s</tt> for character string and<tt>%%</tt> for itself.<p><strong>Exercise 1-3.</strong> Modify the temperature conversion program to print aheading above the table.<p><strong>Exercise 1-4.</strong> Write a program to print the corresponding Celsius toFahrenheit table.<h2><a name="s1.3">1.3 The for statement</a></h2>There are plenty of different ways to write a program for a particular task.Let's try a variation on the temperature converter.<pre>   #include &lt;stdio.h&gt;   /* print Fahrenheit-Celsius table */   main()   {       int fahr;       for (fahr = 0; fahr &lt;= 300; fahr = fahr + 20)           printf("%3d %6.1f\n", fahr, (5.0/9.0)*(fahr-32));   }</pre>This produces the same answers, but it certainly looks different. One majorchange is the elimination of most of the variables; only <tt>fahr</tt> remains,and we have made it an <tt>int</tt>. The lower and upper limits and the stepsize appear only as constants in the <tt>for</tt> statement, itself a newconstruction, and the expression that computes the Celsius temperature nowappears as the third argument of <tt>printf</tt> instead of a separateassignment statement.<p>This last change is an instance of a general rule - in any context where itis permissible to use the value of some type, you can use a more complicatedexpression of that type. Since the third argument of <tt>printf</tt> must bea floating-point value to match the <tt>%6.1f</tt>, any floating-pointexpression can occur here.<p>The <tt>for</tt> statement is a loop, a generalization of the <tt>while</tt>.If you compare it to the earlier <tt>while</tt>, its operation should be clear.Within the parentheses, there are three parts, separated by semicolons. Thefirst part, the initialization<pre>   fahr = 0</pre>is done once, before the loop proper is entered. The second part is the testor condition that controls the loop:<pre>   fahr &lt;= 300</pre>This condition is evaluated; if it is true, the body of the loop (here asingle <tt>ptintf</tt>) is executed. Then the increment step<pre>   fahr = fahr + 20</pre>is executed, and the condition re-evaluated. The loop terminates if thecondition has become false. As with the <tt>while</tt>, the body of the loop canbe a single statement or a group of statements enclosed in braces. Theinitialization, condition and increment can be any expressions.<p>The choice between <tt>while</tt> and <tt>for</tt> is arbitrary, based on whichseems clearer. The <tt>for</tt> is usually appropriate for loops in which theinitialization and increment are single statements and logically related,since it is more compact than <tt>while</tt> and it keeps the loop controlstatements together in one place.<p><strong>Exercise 1-5.</strong> Modify the temperature conversion program toprint the table in reverse order, that is, from 300 degrees to 0.<h2><a name="s1.4">1.4 Symbolic Constants</a></h2>A final observation before we leave temperature conversion forever. It's badpractice to bury ``magic numbers'' like 300 and 20 in a program; they conveylittle information to someone who might have to read the program later, andthey are hard to change in a systematic way. One way to deal with magicnumbers is to give them meaningful names. A <tt>#define</tt> line defines a<em>symbolic name or symbolic constant</em> to be a particular string ofcharacters:<p>&nbsp;&nbsp;<tt>#define</tt>   <em>name   replacement list</em><p>Thereafter, any occurrence of <em>name</em> (not in quotes and not part ofanother name) will be replaced by the corresponding <em>replacement text</em>.The <em>name</em> has the same form as a variable name: a sequence of lettersand digits that begins with a letter. The <em>replacement text</em> can be anysequence of characters; it is not limited to numbers.<pre>   #include &lt;stdio.h&gt;   #define LOWER  0     /* lower limit of table */   #define UPPER  300   /* upper limit */   #define STEP   20    /* step size */   /* print Fahrenheit-Celsius table */   main()   {       int fahr;       for (fahr = LOWER; fahr &lt;= UPPER; fahr = fahr + STEP)           printf("%3d %6.1f\n", fahr, (5.0/9.0)*(fahr-32));   }</pre>The quantities <tt>LOWER</tt>, <tt>UPPER</tt> and <tt>STEP</tt> are symbolicconstants, not variables, so they do not appear in declarations. Symbolicconstant names are conventionally written in upper case so they can berreadily distinguished from lower case variable names. Notice that there is nosemicolon at the end of a <tt>#define</tt> line.<h2><a name="s1.5">1.5 Character Input and Output</a></h2>We are going to consider a family of related programs for processingcharacter data. You will find that many programs are just expanded versionsof the prototypes that we discuss here.<p>The model of input and output supported by the standard library is verysimple. Text input or output, regardless of where it originates or where itgoes to, is dealt with as streams of characters. A <em>text stream</em> is asequence of characters divided into lines; each line consists of zero or morecharacters followed by a newline character. It is the responsibility of thelibrary to make each input or output stream confirm this model; the Cprogrammer using the library need not worry about how lines are representedoutside the program.<p>The standard library provides several functions for reading or writing onecharacter at a time, of which <tt>getchar</tt> and <tt>putchar</tt> are thesimplest. Each time it is called, <tt>getchar</tt> reads the <em>next inputcharacter</em> from a text stream and returns that as its value. That is, after<pre>   c = getchar();</pre>the variable <tt>c</tt> contains the next character of input. The charactersnormally come from the keyboard; input from files is discussed in<a href="chapter7.html">Chapter 7</a>.<p>The function <tt>putchar</tt> prints a character each time it is called:<pre>   putchar(c);</pre>prints the contents of the integer variable <tt>c</tt> as a character, usuallyon the screen. Calls to <tt>putchar</tt> and <tt>printf</tt> may be interleaved;the output will appear in the order in which the calls are made.<h3><a name="s1.5.1">1.5.1 File Copying</a></h3>Given <tt>getchar</tt> and <tt>putchar</tt>, you can write a surprisingamount of useful code without knowing anything more about input and output.The simplest example is a program that copies its input to its output onecharacter at a time:<pre><em>read a character</em>    while (<em>charater is not end-of-file indicator</em>)        <em>output the character just read        read a character</em></pre>Converting this into C gives:<pre>   #include &lt;stdio.h&gt;   /* copy input to output; 1st version  */   main()

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲天堂中文字幕| 欧美高清视频在线高清观看mv色露露十八| 在线观看不卡一区| 一区二区三区四区在线免费观看| av一区二区久久| 亚洲欧美日韩久久精品| 欧美精品在欧美一区二区少妇| 在线亚洲一区观看| 国产精品一区二区在线观看网站| 久久婷婷国产综合国色天香| voyeur盗摄精品| 一本大道av伊人久久综合| 久久精品国产99| 国产精品福利一区二区三区| 欧美精品三级日韩久久| 日韩视频中午一区| 91免费国产视频网站| 国产在线不卡一区| 自拍偷拍亚洲欧美日韩| 一区二区三区日韩欧美精品| 午夜精品久久久久久| 欧美高清在线一区二区| 欧美人妇做爰xxxⅹ性高电影| 丰满亚洲少妇av| 免费日本视频一区| 亚洲天堂中文字幕| 日韩制服丝袜av| 亚洲成a天堂v人片| 亚洲免费伊人电影| 免费成人在线视频观看| 成人av在线资源网站| 国产精品综合一区二区三区| 97精品久久久午夜一区二区三区 | 亚洲精品久久久蜜桃| 久久久久综合网| 日韩欧美国产麻豆| 欧美人妖巨大在线| 欧美激情在线免费观看| 亚洲福利一区二区| 亚洲综合丁香婷婷六月香| 亚洲欧洲综合另类| 日韩av网站免费在线| 日韩精品一二三四| 成人国产免费视频| 精品剧情在线观看| 国产丝袜欧美中文另类| 久久久久久久久岛国免费| 亚洲精品免费视频| 成人福利视频网站| 欧美成人女星排名| 亚洲国产一二三| caoporen国产精品视频| 久久免费精品国产久精品久久久久| 一区二区不卡在线视频 午夜欧美不卡在 | 久久久九九九九| 五月婷婷色综合| 在线观看日韩国产| 亚洲欧洲日韩av| 亚洲一区二区精品视频| 成人激情动漫在线观看| 久久综合狠狠综合久久综合88| 亚洲另类色综合网站| 国产99久久久国产精品免费看| 精品国产一区二区三区久久影院| 久久久青草青青国产亚洲免观| 水野朝阳av一区二区三区| 在线观看国产91| 伊人色综合久久天天人手人婷| 成a人片亚洲日本久久| 欧美国产日韩一二三区| 国产一区二区三区综合| 久久综合九色综合97婷婷| 看片网站欧美日韩| 日韩一区二区麻豆国产| 美女视频免费一区| 色综合天天综合网天天狠天天| 欧美日韩一区三区| 久久综合色综合88| 国内欧美视频一区二区| 在线视频一区二区三| 亚洲精品免费在线观看| 欧美在线观看一区| 午夜精品久久久久久久久久| 欧美性大战久久| 国产午夜精品一区二区| 粉嫩一区二区三区在线看| 国产精品萝li| 奇米888四色在线精品| 日韩精品一区二区三区三区免费| 精品一区二区久久| 欧美日韩一区视频| 日韩av在线播放中文字幕| 日韩精品专区在线影院重磅| 久久成人精品无人区| 欧美韩国日本综合| 日本丶国产丶欧美色综合| 日韩综合小视频| 久久久不卡网国产精品一区| 豆国产96在线|亚洲| 夜夜亚洲天天久久| 91精品国产综合久久香蕉麻豆 | 欧美一卡二卡在线| 亚洲一区二区三区视频在线播放| 欧美日韩卡一卡二| 国产一区二三区| 一区二区三区在线视频免费 | 884aa四虎影成人精品一区| 欧美aa在线视频| 国产精品久久久久久久久快鸭| 欧美性受极品xxxx喷水| 麻豆视频观看网址久久| 亚洲欧洲精品天堂一级| 欧美人狂配大交3d怪物一区| 国产很黄免费观看久久| 久久久美女毛片| 在线观看国产日韩| 风间由美一区二区三区在线观看 | 欧美精品久久99久久在免费线| 国产一区二区三区在线看麻豆| 一区二区三区欧美亚洲| 久久久99免费| 欧美久久婷婷综合色| 成人动漫在线一区| 捆绑紧缚一区二区三区视频| 亚洲综合久久久久| 国产精品欧美综合在线| 日韩美女一区二区三区四区| 欧美中文字幕不卡| heyzo一本久久综合| 国产伦精品一区二区三区视频青涩| 亚洲一二三区不卡| 国产精品久久毛片| 久久精品视频在线看| 欧美一级片在线看| 在线观看91精品国产麻豆| 91亚洲午夜精品久久久久久| 国产成人欧美日韩在线电影| 久久精品久久综合| 秋霞电影一区二区| 婷婷丁香久久五月婷婷| 一区二区三区免费网站| 中文字幕在线一区二区三区| 欧美xxxx在线观看| 91精品国产麻豆国产自产在线| 日本高清不卡在线观看| 色综合一区二区| 色综合久久久久久久久久久| 成人a级免费电影| 99久久伊人精品| 不卡在线观看av| 99精品久久久久久| 91在线免费看| 欧美网站一区二区| 欧美日韩国产首页| 欧美丰满一区二区免费视频| 在线播放欧美女士性生活| 欧美日本在线看| 日韩一区二区三区免费观看| 日韩小视频在线观看专区| 欧美videofree性高清杂交| 日韩精品中文字幕在线不卡尤物| 91精品国产美女浴室洗澡无遮挡| 日韩欧美在线不卡| 久久久久久一二三区| 国产蜜臀av在线一区二区三区| 欧美午夜片在线看| 欧美久久婷婷综合色| 欧美va天堂va视频va在线| 久久亚洲综合色| 中文av一区二区| 亚洲精品写真福利| 美女看a上一区| 成人晚上爱看视频| 精品在线一区二区三区| 国产精品99久久久| 色域天天综合网| 欧美一区二区日韩| 国产嫩草影院久久久久| 亚洲综合在线电影| 另类小说综合欧美亚洲| 99久久99久久精品免费观看 | 精品久久久网站| 亚洲欧洲国产专区| 日本三级亚洲精品| av成人免费在线| 日韩天堂在线观看| 亚洲视频在线观看一区| 日本伊人色综合网| 成人福利视频在线看| 69堂亚洲精品首页| 国产精品国产三级国产三级人妇| 亚洲国产精品一区二区www在线| 国内成+人亚洲+欧美+综合在线 | 久久一区二区三区国产精品| 亚洲视频在线观看三级| 久久99在线观看| 欧美日韩的一区二区| 欧美激情综合在线| 美女网站在线免费欧美精品| 一本一道久久a久久精品|