slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
IF 语句的嵌套 PowerPoint Presentation
Download Presentation
IF 语句的嵌套

Loading in 2 Seconds...

  share
play fullscreen
1 / 5
kenyon-perry

IF 语句的嵌套 - PowerPoint PPT Presentation

127 Views
Download Presentation
IF 语句的嵌套
An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. IF 语句的嵌套 练一练: 1、输入一个整数,判断它是否能同时被 3、5整除,是则输出“YES”,否则输出“NO”; 如果能被其中一个整除,请说明是哪个数。 算法描述: ⑴输入一个整数N ⑵如果N MOD 3=0 则判断N MOD 5是否为0;是则输出 “YES”,否则输出能被3整除 ⑶如果N MOD 3<>0则判断N MOD 5是否为0;是则输出 能被5整除,否则输出“NO” ⑷结束

  2. INPUT “N=”;N IF N MOD 3=0 THEN IF N MOD 5=0 THEN PRINT “YES” ELSE PRINT “NENG BEI 3 ZHENG CHU” END IF ELSE IF N MOD 5=0 THEN PRINT “NENG BEI 5 ZHENG CHU” ELSE PRINT “NO” END IF END IF END

  3. +1(x>0) 0(x=0) -1(x<0) 输入x的值,输出y的值。 2、有一个函数y= INPUT “x=”;x IF x>0 THEN y=1 ELSE IF x=0 THEN y=0 ELSE y=-1 ENDIF ENDIF PRINT “x=”;x;”y=”;y END

  4. IF语句的嵌套练习 y 3 、输入一个实数,判断它在平面 直角坐标系中所在的象限。 第一象限 x>0,y>0 第二象限 x<0,y>0 第三象限 x<0,y<0 第四象限 x>0,y<0 Ⅱ Ⅰ 0 x Ⅳ Ⅲ

  5. 程序如下: INPUT “x,y=”;x,y IF x>0 THEN IF y>0 THEN PRINT x;”and”;y;”is in first quadrant” ELSE PRINT x;”and”;y;”is in fourth quadrant” END IF ELSE IF y>0 THEN PRINT x;”and”;y;”is in second quadrant” ELSE PRINT x;”and”;y;”is in third quadrant” END IF END IF END