Wednesday, January 18, 2006

參考程式:
====================
#include
void main()
{
int a,b;

printf("Please enter 2 integer.");
scanf("%d%d",&a,&b);
printf("%d\n",a+b);

}

====================

課堂練習:
請print出
Please enter how many dogs you have.
/*輸入第一個數值*/
Please enter how many cats you have.
/*輸入第二個數值*/
I have a dogs.
I have b cats.
I have a+b pats.
紅色部分為自己輸入的數字

13 Comments:

At Wed Jan 18, 06:58:00 PM, Anonymous Anonymous said...

#include stdio.h
void main()
{
int a,b;
scanf("%d%d",&a,&b);
printf("I have %d dogs.\n",a);
printf("I have %d cats.\n",b);
printf("I have %d oets.\n",a+b);
}

 
At Wed Jan 18, 07:03:00 PM, Anonymous Anonymous said...

#include stdio.h
void main()
{
int a,b;
printf("Please enter how many dogs you have.\n");
scanf("%d",&a);
printf("Please enter how many cats you have.\n");
scanf("%d",&b);
printf("I have %d dogs.\n",a);
printf("I have %d cats.\n",b);
printf("I have %d oets.\n",a+b);
}

 
At Wed Jan 18, 07:05:00 PM, Anonymous Anonymous said...

#include stdio.h
void main()
{
int a,b;

printf ("我有幾隻貓?\n");
scanf ("%d",&a);
printf ("你有幾隻貓?\n");
scanf ("%d",&b);

printf ("我們總共有 %d 隻貓\n",a+b);
}

 
At Wed Jan 18, 07:06:00 PM, Anonymous Anonymous said...

QQ


#include stdio.h
void main()
{
int a,b;
printf("How many brothers do you have?\n");
scanf("%d",&a);
printf("I have %d brothers\n",a);
printf("How many sisters do you have?\n");
scanf("%d",&b);
printf("I have %d sisters\n",b);
printf("How many peoples do you have in your family?\n");
printf("There are %d peoples in my family\n",a+b+3);
}

 
At Wed Jan 18, 07:13:00 PM, Anonymous Anonymous said...

#include < stdio.h >
int main()
{
int a,b;
printf("Please enter how many dogs you have.\n");
scanf("%d",&a);
printf("Please enter how many cats you have.\n");
scanf("%d",&b);
printf("I have %d dogs.\n",a);
printf("I have %d cats.\n",b);
printf("I have %d pats.\n",a+b);
return 0;
}

 
At Wed Jan 18, 07:14:00 PM, Anonymous Anonymous said...

okok

 
At Wed Jan 18, 07:15:00 PM, Anonymous Anonymous said...

#include "stdio.">//""用<>代換
void main()
{
int a,b;

printf("Please enter how many dogs you have.");
scanf("%d",&a);
/*輸入第一個數值*/
printf("Please enter how many cats you have.");
scanf("%d",&b);
/*輸入第二個數值*/
printf("I have %d dogs.\n",a);
printf("I have %d cats.\n",b);
printf("I have %d pats.\n",a+b);
}

 
At Wed Jan 18, 07:17:00 PM, Anonymous Anonymous said...

#include"stdio.h"
void main()
{

int a,b;
printf("Please enter how many dogs you have.\n");
scanf("%d",&a);
printf("I have %d dogs.\n",a);
printf("Please enter how many cats you have.\n");
scanf("%d",&b);
printf("I have %d dogs.\n",b);
printf("I have %d pats.\n",a+b);
}

 
At Wed Jan 18, 07:19:00 PM, Anonymous Anonymous said...

#include "stdio.h"
void main()
{
int a,b;
printf("please enter how many dogs you have\n.");
scanf("%d",&a);
printf("please enter how many cats you have\n.");
scanf("%d",&b);
printf("i have %d dogs.\n",a);
printf("i have %d cats.\n",b);
printf("i have %d pats.\n",a+b);
}

 
At Wed Jan 18, 07:19:00 PM, Anonymous Anonymous said...

#include stdio.h
void main()
{
int a,b;
printf("please enter how many dogs you have\n.");
scanf("%d",&a);
printf("please enter how many cats you have\n.");
scanf("%d",&b);
printf("i have %d dogs.\n",a);
printf("i have %d cats.\n",b);
printf("i have %d pats.\n",a+b);
}

 
At Wed Jan 18, 07:21:00 PM, Anonymous Anonymous said...

#include stdio.h
void main()
{
int a,b;

printf("Please enter how many dogs you have.\n");
printf("Please enter how many cats you have.\n");

scanf("%d",&a);
printf("I have %d dogs.\n",a);
scanf("%d",&b);
printf("I have %d cats.\n",b);

printf("I have %d pats.\n",a+b);

}

 
At Wed Jan 18, 07:37:00 PM, Anonymous Anonymous said...

#include stdio.h
void main(void)
{
int a,b;
printf("Please enter how many dogs you have.");
scanf("%d",&a);
printf("Please enter how many cats you have.");
scanf("%d",&b);
printf("%d\n",a*b);
}
跑起來怪怪的~

 
At Wed Jan 18, 07:37:00 PM, Blogger Aclose said...

給北極熊~~
嗯嗯...還不錯...
你有記得把你和你父母當成自己的家人

 

Post a Comment

<< Home