2013年11月8日 星期五

平方表

#include<iostream>
#include<cstdlib>
using namespace std;
main()
{
int a,b,c,d,e,f;
for(a=1;a<99;a++)
{
       cout<<a*a<<endl;
}
}
#include<iostream> 
#include<cstdlib> 
using namespace std;
 main()
 {
int a;
 cout<<"你答對的題目有多少題?"<<endl;
 cin>>a;
 cout<<"你的分數是:";
if(a<=10)
 {
 cout<<a*6<<endl;
 }
 else if(a<20)
 {
 cout<<10*6+(a-10)*2<<endl;
 }
 else if(a<39)
 {
 cout<<80+(a-20)*1<<endl;
 }
 else
 {
 cout<<60+40<<endl;
 }
 }
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
⋯⋯int a,b,c,d;
cout<<"請輸入1個月份"<<endl;
cin>>a;
cout<<"請輸入1個日"<<endl;
cin>>b;
if ((a*2+b)%3==0)
{
cout<<"運勢是大吉"<<endl;
}
else if ((a*2+b)%3==1)
{
cout<<"運勢是普通"<<endl;
}
else
{
cout<<"運勢是大凶"<<endl;
}
}

2013年11月1日 星期五

四種面積


#include<iostream>
#include<cstdlib>
using namespace std;
int Square()

{
 int x,y;
 cout<<"請輸入邊長"<<endl;
 cin>>x;
 y=x*x;
 cout<<y<<endl;
system("pause");
}
int Rectangle()
{
 int x,y,z;
 cout<<"請輸入寬"<<endl;
 cout<<"請輸入長"<<endl;
 cin>>x>>y;
 z=x*y;
 cout<<z<<endl;
  system("pause");
}
int  Circle()
{
 float x,y;
 cout<<"請輸入半徑"<<endl;
 cin>>x;
 y=x*x*3.14;
 cout<<y<<endl;
 system("pause");
}
int Trapezoidal()
{
 int x,y,z,a;
 cout<<"請輸入上底"<<endl;
 cout<<"請輸入下底"<<endl;
 cout<<"請輸入高"<<endl;
 cin>>x>>y>>z;
 a=(x+y)*z/2;
 cout<<a<<endl;
 system("pause");
}
main()
{
 int x;
 cout<<"請選擇要計算面積的圖形"<<endl;
    cout<<"1)正方形,2)長方形,3)圓形, 4)梯形"<<endl;
    cin>>x;
    switch(x)
    {
 case 1:
     Square();
 case 2:
     Rectangle();
    case 3:
     Circle();
 case 4:
     Trapezoidal();
 }
}

乘以二


作品1