Ads 468x60px

##EasyReadMore##

08 9月, 2010

C 程式語言 作業 之 <比大>

#include<stdio.h>
int main(void)
{
int Number1,Number2;
while(1)
{
printf("Number1="); //輸入第一個數字//
scanf("%d",&Number1);
printf("Number2="); //輸入第二個數字//
scanf("%d",&Number2);
if(Number1>Number2) //如果Number1>Number2//
printf("%d is larger\n",Number1); //則Number1 is larger//
else
if(Number1<Number2) //如果Number1<Number2//
printf("%d is larger\n",Number2); //則Number2 is larger//
else
printf("These numbers are equal\n");
//如果一樣大則出現These numbers are equal//
}
}

以下是程式執行後的結果...
例一:
Number1= 123
Number2= 456
456 is larger
例二:
Number1= 456
Number2= 123
456 is larger
例三:
Number1= 123
Number2= 123
These numbers are equal

0 意見:

張貼留言

 
Blogger Templates