導航:首頁 > 源碼編譯 > tanlas源碼

tanlas源碼

發布時間:2022-08-20 04:04:34

Ⅰ 如何運行fortran源代碼

你已的編譯器已經能夠完全正常運行,而且程序也可以運行了呢,只是你不知道如何運行它而已!

在unix或linux下編譯fortran,一般系統沒有自帶fortran的編譯器,可以自行安裝g77或gfortran編譯器,它們是gcc一個系列的,也可以下載單獨的g95編譯器。

假定你的fortran源程序為hello.for

則輸入如下的命令來編譯它(g77、gfortran、g95)
g77 hello.for
這樣就會在當前目錄生成a.out的可執行文件,這樣既可執行
./a.out

如果需要指定生成的文件名,可以加個參數-o 來制定文件名,像這樣
g77 -o hello hello.for
./hello

明白了嗎?unix類操作系統的執行檔,並不需要.exe這樣的擴展名的。

Ⅱ 用c++實現有界面的計算器,求源代碼

我用的是MFC實現的,功能基本上都有了,而且還加了矩陣以及行列式的計算,你適當修改吧。不過這個東西最好自己做才有收獲。
下面的代碼是核心的部分的代碼,我已經寫了很久了,所以很多東西都忘記了,還好有注釋,最好自己做吧,有了思想,什麼都好解決。
你要是有郵箱的話我打包給你,畢竟這個只是一部分,其它的調用你是看不到的。
// MyDialog.cpp : implementation file
//

#include "stdafx.h"
#include "Calculator.h"
#include "MyDialog.h"
#include "math.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// MyDialog dialog
CString str="dddd";
char num[200]; //記錄輸入的數據
int count=0; //記錄數據個數,回退時要減一
char a; //記錄操作符
double x,y; //兩個操作數
double result; //得到結果
#define PI 3.141592653

MyDialog::MyDialog(CWnd* pParent /*=NULL*/)
: CDialog(MyDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(MyDialog)
str = _T("");
//}}AFX_DATA_INIT
}

void MyDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(MyDialog)
DDX_Control(pDX, IDC_BUTTON2, m_2);
DDX_Control(pDX, IDC_BUTTON1, m_1);
DDX_Text(pDX, IDC_EDIT1, str);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(MyDialog, CDialog)
//{{AFX_MSG_MAP(MyDialog)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
ON_BN_CLICKED(IDC_BUTTON7, OnButton7)
ON_BN_CLICKED(IDC_BUTTON8, OnButton8)
ON_BN_CLICKED(IDC_BUTTON9, OnButton9)
ON_BN_CLICKED(IDC_BUTTON10, OnButton10)
ON_BN_CLICKED(IDC_BUTTON11, OnButton11)
ON_BN_CLICKED(IDC_BUTTON12, OnButton12)
ON_BN_CLICKED(IDC_BUTTON13, OnButton13)
ON_BN_CLICKED(IDC_BUTTON14, OnButton14)
ON_BN_CLICKED(IDC_BUTTON15, OnButton15)
ON_BN_CLICKED(IDC_BUTTON16, OnButton16)
ON_NOTIFY(MCN_GETDAYSTATE, IDC_MONTHCALENDAR1, OnGetdaystateMonthcalendar1)
ON_BN_CLICKED(IDC_BUTTON17, OnButton17)
ON_BN_CLICKED(IDC_BUTTON18, OnButton18)
ON_BN_CLICKED(IDC_BUTTON19, OnButton19)
ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit2)
ON_BN_CLICKED(IDC_BUTTON20, OnButton20)
ON_BN_CLICKED(IDC_BUTTON21, OnButton21)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// MyDialog message handlers
void MyDialog::OnChangeEdit1()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.

// TODO: Add your control notification handler code here
// GetDlgItem(IDC_EDIT1)-> SetWindowText(str);
// CEdit* pBoxOne;
// pBoxOne = (CEdit*) GetDlgItem(IDC_EDIT1);
// pBoxOne->SetWindowText(str);
}

void MyDialog::OnButton1()
{
// TODO: Add your control notification handler code here
str=str+"1";
num[count]='1';
++count;
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
}

void MyDialog::OnButton2()
{
// TODO: Add your control notification handler code here
str=str+"2";
num[count]='2';
++count;
GetDlgItem(IDC_EDIT1)->SetWindowText(str);

}

void MyDialog::OnButton3()
{
// TODO: Add your control notification handler code here
num[count]='3';
++count;
str=str+"3";
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
}

void MyDialog::OnButton4()
{
// TODO: Add your control notification handler code here
num[count]='4';
++count;
str=str+"4";
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
}

void MyDialog::OnButton5()
{
// TODO: Add your control notification handler code here
str=str+"5";
num[count]='5';
++count;
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
}

void MyDialog::OnButton6()
{
// TODO: Add your control notification handler code here
str=str+"6";
num[count]='6';
++count;
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
}

void MyDialog::OnButton7()
{
// TODO: Add your control notification handler code here
str=str+"7";
num[count]='7';
++count;
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
}

void MyDialog::OnButton8()
{
// TODO: Add your control notification handler code here
str=str+"8";
num[count]='8';
++count;
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
}

void MyDialog::OnButton9()
{
// TODO: Add your control notification handler code here
str=str+"9";
num[count]='9';
++count;
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
}

void MyDialog::OnButton10()
{
// TODO: Add your control notification handler code here
str=str+"0";
num[count]='0';
++count;
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
}

void MyDialog::OnButton11()
{
// TODO: Add your control notification handler code here
str=str+".";
++count;
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
}

void MyDialog::OnButton12() //等號
{
// TODO: Add your control notification handler code here
char c;
c=a;
y=0;
for(int i=0;i<count;++i)
{
y=(num[i]-48)+y*10;
}
count=0;
switch(c)
{
case'+':
result=x+y;break;
case'-':
result=x-y;break;
case'*':
result=x*y;break;
case'/':
{
if(y==0)
{
str="除數為0 ! 出錯 !";
goto Lable;
}
result=x/y;break;
}
default:
break;
}
str.Format("%f",result);
Lable:
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
str="";
}

void MyDialog::OnButton13()
{
// TODO: Add your control notification handler code here
str=str+"+";
a='+';
x=0;
for(int i=0;i<count;++i)
{
x=(num[i]-48)+x*10;
}
count=0;
// str.Format("%f",x);
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
}

void MyDialog::OnButton14()
{
// TODO: Add your control notification handler code here
str=str+"-";
a='-';
x=0;
for(int i=0;i<count;++i)
{
x=(num[i]-48)+x*10;
}
count=0;
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
}

void MyDialog::OnButton15()
{
// TODO: Add your control notification handler code here
str=str+"*";
a='*';
x=0;
for(int i=0;i<count;++i)
{
x=(num[i]-48)+x*10;
}
count=0;
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
}

void MyDialog::OnButton16()
{
// TODO: Add your control notification handler code here
str=str+"/";
a='/';
x=0;
for(int i=0;i<count;++i)
{
x=(num[i]-48)+x*10;
}
count=0;
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
}

void MyDialog::OnButton17()
{
// TODO: Add your control notification handler code here
x=0;
for(int i=0;i<count;++i)
{
x=(num[i]-48)+x*10;
}
x=x*PI/180; //轉換為弧度
result=sin(x);
str.Format("%f",result);
GetDlgItem(IDC_EDIT1)->SetWindowText(str); //在EDIT文本框中顯示數據
count=0;
str="";
}

void MyDialog::OnButton18()
{
// TODO: Add your control notification handler code here
x=0;
for(int i=0;i<count;++i)
{
x=(num[i]-48)+x*10;
}
x=x*PI/180; //轉換為弧度
result=cos(x);
str.Format("%f",result);
GetDlgItem(IDC_EDIT1)->SetWindowText(str); //在EDIT文本框中顯示數據
count=0;
str="";
}

void MyDialog::OnButton19()
{
// TODO: Add your control notification handler code here
x=0;
for(int i=0;i<count;++i)
{
x=(num[i]-48)+x*10;
}
x=x*PI/180; //轉換為弧度
result=tan(x);
str.Format("%f",result);
GetDlgItem(IDC_EDIT1)->SetWindowText(str); //在EDIT文本框中顯示數據
count=0;
str="";
}

void MyDialog::OnGetdaystateMonthcalendar1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here

*pResult = 0;
}

///有關於求逆矩陣的函數
int numbers=0; //記錄矩陣元素的個數

void MyDialog::OnChangeEdit2()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.

// TODO: Add your control notification handler code here

}

void MyDialog::OnButton20()
{
// TODO: Add your control notification handler code here

int i=0,j=0;
CString str1="";
//*************************統計整數個數!************************
GetDlgItem(IDC_EDIT2)->GetWindowText(str);
while(str[i]!=';')
{
++i;
if(str[i]==',')
{
++j;
}
}
++j;
numbers=j;
int n;
if(Judge(numbers)) //矩陣元素個數符合要求
{
// str.Format("%d",numbers);
// GetDlgItem(IDC_EDIT1)->SetWindowText(str);
n=sqrt(numbers);
}
else
{
str1="元素個數有誤 ! 請在已經輸入的基礎上改正 !";
GetDlgItem(IDC_EDIT1)->SetWindowText(str1);
str1="";
}
//*************************************************

}

bool MyDialog::Judge(int numbers) //判斷矩陣的元素個數是否符合條件,及是否是n X n的矩陣
{
if(numbers!=int(sqrt(numbers))*int(sqrt(numbers)))
{
return 0;
}
else
return 1;
}

void Hanglieshi(double **a,int N); //求行列式的值,使用以前的代碼,在函數參數方面有點調整
void plus(double **a,double **b,double **c,int m,int n);//m x n 的矩陣相加
void multiply(double **a,double **b,double **result,int m,int n,int l);//m x n 的矩陣 與 n x l 的矩陣的乘積
double **allocation(int m,int n); //動態分配二維數組,大小:m x n
void swap(double **a,int m,int n,int N); //交換m行和n行的內容
void add(double **a,int m,int n,int N); //把第n行加到第m行上面
void jian(double **a,int m,int n,double x,int N); //用m行減去n行的k倍
int judgeZero(double **a,int j,int N); //返回j列沒有0的元素的位置
void dealZero(double **a,int N); //判斷主對角線是否有值為0的元素,如果有,則加上對應列上沒有0的行
void dealArray(double **a,int N); //將行列式化為上三角行列式
double jieguo(double **a,int N); //主對角線元素之積,即行列式的值

void MyDialog::OnButton21() //求行列式的值
{
// TODO: Add your control notification handler code here
int i=0,j=0;
double res;
CString str1="";
CString str2="";
//*************************統計整數個數!************************
GetDlgItem(IDC_EDIT2)->GetWindowText(str1); //str1為文本框中的數據字元串
while(str1[i]!=';')
{
++i; //統計總字元個數
if(str1[i]==',')
{
++j; //統計整數個數
}
}
++j;
int N=i;
numbers=j;

int num;
if(Judge(numbers)) //矩陣元素個數符合要求
{
str.Format("%d",numbers);
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
num=sqrt(numbers);
double **a; // 動態二維數組
double var; //轉換使用的變數
int m,n,l;
m=n=num;
a=allocation(m,n);
//***************************無法解決轉換中出現的問題,設置臨時一維數組參與轉換,然後再賦值到二維數組中
double *Arr=new double[numbers];
//
m=0;
n=0;
str2=str1;
i=0;
while(1) //對數組進行賦值
{
if(str2[n]!=',')
{
var=atoi(str2);
Arr[m]=var;
++m;
++n;
}
else
{
str2="";
for(l=i;l<N;++l) //將文本框裡面的已經轉換的數據去掉,取其餘下的部分
{
str2=str2+str1[l];
}
n=0;
}
++i;
if(i==N+1)
break;
}
// str.Format("%f",Arr[1]); //調試時使用
// GetDlgItem(IDC_EDIT1)->SetWindowText(str);

m=0;
for(i=0;i<num;++i)
{
for(j=0;j<num;++j)
{
a[i][j]=Arr[m];
++m;
}
}

// str.Format("%f",Arr[3]); //調試時使用
// GetDlgItem(IDC_EDIT1)->SetWindowText(str);

n=num;
Hanglieshi(a,n);
var=jieguo(a,n);
str.Format("%f",var);
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
delete []Arr;
}
else
{
str1="元素個數有誤 ! 請在已經輸入的基礎上改正 !";
GetDlgItem(IDC_EDIT1)->SetWindowText(str1);
str1="";
}
}

//*******************行列式求值部分
/*void print(double **a,int m,int n)//輸出m x n 的矩陣的內容
{
for(int i=0;i<m;++i)
{
for(int j=0;j<n;++j)
{
cout<<setw(3)<<a[i][j];
}
cout<<endl;
}
}
*/
void plus(double **a,double **b,double **c,int m,int n)//m x n 的矩陣相加
{
for(int i=0;i<m;++i)
{
for(int j=0;j<n;++j)
{
c[i][j]=a[i][j]+b[i][j];
}
}
}

void multiply(double **a,double **b,double **result,int m,int n,int l)//m x n 的矩陣 與 n x l 的矩陣的乘積
{
// cout<<"兩個矩陣相乘的結果為: "<<endl;
int i,j,k;
for(i=0;i<m;++i)
{
for(j=0;j<l;++j)
{
result[i][j]=0;
for(k=0;k<n;++k)
{
result[i][j]=result[i][j]+a[i][k]*b[k][j];
}
}
}
}

double **allocation(int m,int n) //動態分配二維數組,大小:m x n
{
double **a;
a=new double *[m];
for(int i=0;i<m;++i)
{
a[i]=new double [n];
}
return a;
}
/*
void printArray(double **a,int N) //輸出矩陣內容
{
for(int i =0 ; i<N ; ++i )
{
for(int j = 0; j<N; ++j)
cout<<a[i][j]<<" ";
cout<<endl;
}
cout<<endl;
}
*/
void swap(double **a,int m,int n,int N) //交換m行和n行的內容
{
int i,j;
double *temp=new double[N];
for(j=0;j<N;++j)
{
temp[j]=a[m][j];
a[m][j]=a[n][j];
a[n][j]=temp[j];
}

}

void add(double **a,int m,int n,int N) //把第n行加到第m行上面
{
int i;
for(i=0;i<N;++i)
{
a[m][i]+=a[n][i];
}
}

void jian(double **a,int m,int n,double x,int N) //用m行減去n行的k倍
{
for(int j=0;j<N;++j)
{
a[m][j]=a[m][j]-x*a[n][j];
}
}

int judgeZero(double **a,int j,int N) //返回j列沒有0的元素的位置
{
int i;
for(i=0;i<N;++i)
{
if(a[i][j]!=0)
return i;
}
return -1; //如果某一列都為0的話
}

void dealZero(double **a,int N) //判斷主對角線是否有值為0的元素,如果有,則加上對應列上沒有0的行
{
int j,m=-1;
for(j=0;j<N;++j)
{
if(a[j][j]==0)
{
m=judgeZero(a,j,N);
if(m==-1)
;
// cout<<"行列式的值為0 !"<<endl;
else
{
add(a,j,m,N);
}
}
}
}

void dealArray(double **a,int N) //將行列式化為上三角行列式
{
int i,j;
double x;
for(i=0;i<N-1;++i)
{
for(j=i+1;j<N;++j)
{
if(a[i][i]==0)
break;
x=a[j][i]/a[i][i];
jian(a,j,i,x,N);
}
}
}

double jieguo(double **a,int N) //主對角線元素之積,即行列式的值
{
double r=1;
for(int i=0;i<N;++i)
r*=a[i][i];
return r;
}

void Hanglieshi(double **a,int N) //求行列式的值,使用以前的代碼,在函數參數方面有點調整
{
// printArray(a,N);
dealZero(a,N);

dealArray(a,N);
// printArray(a,N);

// cout<<jieguo(a,N)<<endl<<endl;
}

Ⅲ 跪求一個用vb設計的有三角函數功能的計算器,需要源代碼,最好是有課程設計,期末作業你懂的!

'給你在msdn上找了一下函數定義並整理了一下,可以用combo做個函數列表用select case調用函數,或者用command控制項數組調用函數,接下來的就是純體力活了,調用函數是注意數據類型,可能是弧度也可能是角度。
sin 基本函數
cos 基本函數
tan 基本函數
atn 基本函數
Secant(正割) Sec(X) = 1 / Cos(X)
Cosecant(餘割) Cosec(X) = 1 / Sin(X)
Cotangent(餘切) Cotan(X) = 1 / Tan(X)
Inverse Sine(反正弦) Arcsin(X) = Atn(X / Sqr(-X * X + 1))
Inverse Cosine (反餘弦) Arccos(X) = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
Inverse Secant (反正割) Arcsec(X) = Atn(X / Sqr(X * X - 1)) + Sgn((X) - 1) * (2 * Atn(1))
Inverse Cosecant (反餘割) Arccosec(X) = Atn(X / Sqr(X * X - 1)) + (Sgn(X) - 1) * (2 * Atn(1))
Inverse Cotangent (反餘切) Arccotan(X) = Atn(X) + 2 * Atn(1)
Hyperbolic Sine (雙曲正弦) HSin(X) = (Exp(X) - Exp(-X)) / 2
Hyperbolic Cosine (雙曲餘弦) HCos(X) = (Exp(X) + Exp(-X)) / 2
Hyperbolic Tangent (雙曲正切) HTan(X) = (Exp(X) - Exp(-X)) / (Exp(X) + Exp(-X))
Hyperbolic Secant (雙曲正割) HSec(X) = 2 / (Exp(X) + Exp(-X))
Hyperbolic Cosecant(雙曲餘割) HCosec(X) = 2 / (Exp(X) - Exp(-X))
Hyperbolic Cotangent(雙曲餘切) HCotan(X) = (Exp(X) + Exp(-X)) / (Exp(X) - Exp(-X))
Inverse Hyperbolic Sine(反雙曲正弦) HArcsin(X) = Log(X + Sqr(X * X + 1))
Inverse Hyperbolic Cosine(反雙曲餘弦) HArccos(X) = Log(X + Sqr(X * X - 1))
Inverse Hyperbolic Tangent(反雙曲正切) HArctan(X) = Log((1 + X) / (1 - X)) / 2
Inverse Hyperbolic Secant(反雙曲正割) HArcsec(X) = Log((Sqr(-X * X + 1) + 1) / X)
Inverse Hyperbolic Cosecant (反雙曲餘割) HArccosec(X) = Log((Sgn(X) * Sqr(X * X + 1) + 1) / X)
Inverse Hyperbolic Cotangent (反雙曲餘切) HArccotan(X) = Log((X + 1) / (X - 1)) / 2

Ⅳ 誰知道通達信函數tan與slope的區別源代碼計算原理如何

tan是一個角的正切值。而slope是線性回歸的斜率,即
y=ax+b
中的
a。在若干個自變數X與其對應的因變數Y值,通過計算出其近似的
y=ax+b
關系。
==================
補充:
請參閱:網路——回歸分析法
http://ke..com/view/540285.htm#sub540285

java 寫的計算器源代碼只實現加減乘除四則運算即可

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Vector;
public class calculator
{
String str1="0"; //運算數1 初值一定為0 為了程序的安全
String str2="0"; //運算數2
String fh="+"; //運算符
String jg="";//結果
//狀態開關 重要
int k1=1;//開關1 用於選擇輸入方向 將要寫入str2或 str2
int k2=1;//開關2 符號鍵 次數 k2>1說明進行的是2+3-9+8 這樣的多符號運算
int k3=1;//開關3 str1 是否可以被清0 ==1時可以 !=1時不能被清0
int k4=1;//開關4 str2 同上
int k5=1;//開關5 控制小數點可否被錄入 ==1時可以 !=1 輸入的小數點被丟掉
JButton jicunqi; //寄存器 記錄 是否連續按下符號鍵
Vector vt=new Vector(20,10);
JFrame frame=new JFrame("sunshine---計算器");
JTextField jg_TextField=new JTextField(jg,20);//20列
JButton clear_Button=new JButton("清除");
JButton button0=new JButton("0");
JButton button1=new JButton("1");
JButton button2=new JButton("2");
JButton button3=new JButton("3");
JButton button4=new JButton("4");
JButton button5=new JButton("5");
JButton button6=new JButton("6");
JButton button7=new JButton("7");
JButton button8=new JButton("8");
JButton button9=new JButton("9");
JButton button_Dian=new JButton(".");
JButton button_jia=new JButton("+");
JButton button_jian=new JButton("-");
JButton button_cheng=new JButton("*");
JButton button_chu=new JButton("/");
JButton button_dy=new JButton("=");
public static void main(String[] args)
{
calculator calculator=new calculator();
}
calculator()
{
jg_TextField.setHorizontalAlignment(JTextField.RIGHT );//文本框 右對齊
JPanel pan=new JPanel();
pan.setLayout(new GridLayout(4,4,5,5));//四行四列 邊距為5像素
pan.add(button7);
pan.add(button8);
pan.add(button9);
pan.add(button_chu);
pan.add(button4);
pan.add(button5);
pan.add(button6);
pan.add(button_cheng);
pan.add(button1);
pan.add(button2);
pan.add(button3);
pan.add(button_jian);
pan.add(button0);
pan.add(button_Dian);
pan.add(button_dy);
pan.add(button_jia);
pan.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));//pan對象的邊距
JPanel pan2=new JPanel();
pan2.add(jg_TextField);
JPanel pan3=new JPanel(); //為什麼要 多此一句呢? 因為我不會設置 按鈕的大小
pan3.setLayout(new FlowLayout());
pan3.add(clear_Button);
//clear_Button.setSize(10,10);//設置清零按鈕的大小 嗎的 不好使 !!
frame.setLocation(300, 200); //主窗口 出現在位置
frame.setResizable(false); //不能調大小
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(pan2,BorderLayout.NORTH);
frame.getContentPane().add(pan,BorderLayout.CENTER);
frame.getContentPane().add(pan3,BorderLayout.SOUTH);
frame.pack();
frame.setVisible(true);
//以上是 控制項 和 布局
//下面是事件處理 程 序
//--------------- 數 字 鍵 ----------------
class JianTing implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String ss=((JButton)e.getSource()).getText();
jicunqi=(JButton)e.getSource();
vt.add(jicunqi);
if (k1==1)
{
if(k3==1)
{
str1="";
k5=1;//還原開關k5狀態
}
str1=str1+ss;
//k2=1;
k3=k3+1;
//System.out.println(str1);
jg_TextField.setText(str1);//顯示
}
else if(k1==2)
{
if (k4==1)
{
str2="";
k5=1; //還原開關k5狀態
}
str2=str2+ss;
//k2=2;
k4=k4+1;
///////////////測試////////////////
jg_TextField.setText(str2);
}
}
}

//--------符 號-----------
class JianTing_fh implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String ss2=((JButton)e.getSource()).getText();
jicunqi=(JButton)e.getSource();
vt.add(jicunqi);
if(k2==1)
{
k1=2;//開關 k1 為1時,向數1寫 為2時,向數2寫
k5=1;
fh=ss2;
k2=k2+1;//按符號鍵的次數
}
else
{
int a=vt.size();
JButton c=(JButton)vt.get(a-2); if(!(c.getText().equals("+"))&&!(c.getText().equals("-"))&&!(c.getText().equals("*"))&&!(c.getText().equals("/")))
{
yuns();
str1=jg;
k1=2;//開關 k1 為1時,向數1寫 為2時,向數2寫
k5=1;
k4=1;
fh=ss2;
} k2=k2+1;
}
}
}
//--------清除-------
class JianTing_clear implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
jicunqi=(JButton)e.getSource();
vt.add(jicunqi);
k5=1;
k2=1;
k1=1;
k3=1;
k4=1;
str1="0";
str2="0";
fh="";
jg="";
jg_TextField.setText(jg);
vt.clear();
}
}
//----------------等 於 ---------------------
class JianTing_dy implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
jicunqi=(JButton)e.getSource();
vt.add(jicunqi);
yuns();
k1=1; //還原開關k1狀態
//str1=jg;
k2=1;
k3=1;//還原開關k3狀態
k4=1; //還原開關k4狀態
str1=jg; //為7+5=12 +5=17 這種計算做准備
}
}
//----------------小數點 ---------------------
class JianTing_xiaos implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
jicunqi=(JButton)e.getSource();
vt.add(jicunqi);
if(k5==1)
{
String ss2=((JButton)e.getSource()).getText();
if (k1==1)
{
if(k3==1)
{
str1="";
k5=1; //還原開關k5狀態
}
str1=str1+ss2;
//k2=1;
k3=k3+1;
//System.out.println(str1);
jg_TextField.setText(str1);//顯示
}
else if(k1==2)
{
if (k4==1)
{
str2="";
k5=1; //還原開關k5狀態
}
str2=str2+ss2;
//k2=2;
k4=k4+1;
///////////////測試////////////////
jg_TextField.setText(str2);
}
}
k5=k5+1;
}
}
//注冊 監聽器
JianTing_dy jt_dy=new JianTing_dy();
JianTing jt= new JianTing();//臨聽數字鍵
JianTing_fh jt_fh= new JianTing_fh();//臨 聽符 號鍵
JianTing_clear jt_c=new JianTing_clear(); //清除鍵
JianTing_xiaos jt_xs=new JianTing_xiaos();// 小數點 鍵
button7.addActionListener(jt);
button8.addActionListener(jt);
button9.addActionListener(jt);
button_chu.addActionListener(jt_fh);
button4.addActionListener(jt);
button5.addActionListener(jt);
button6.addActionListener(jt);
button_cheng.addActionListener(jt_fh);
button1.addActionListener(jt);
button2.addActionListener(jt);
button3.addActionListener(jt);
button_jian.addActionListener(jt_fh);
button0.addActionListener(jt);
button_Dian.addActionListener(jt_xs);
button_dy.addActionListener(jt_dy);
button_jia.addActionListener(jt_fh);
clear_Button.addActionListener(jt_c);
//關閉事件處理程序
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
//---------------計 算------------------
public void yuns()
{
double a2,b2;//運算數1,2
String c=fh;// 運算符
double jg2=0 ;//結果
if (c.equals(""))
{
//System.out.println("請輸入運算符");
jg_TextField.setText("請輸入運算符");
}
else
{
System.out.println("str1:"+str1);//調試時 使 用
System.out.println("str2:"+str2);//調試時 使 用
System.out.println("運算符:"+fh);//調試時 使 用
if (str1.equals(".")) //字元串 "." 轉換成double型數據時 會出錯 所以手工轉
str1="0.0";
if (str2.equals("."))
str2="0.0";
a2=Double.valueOf(str1).doubleValue();
b2=Double.valueOf(str2).doubleValue();
System.out.println("double型的a2:"+a2); //調試時 使 用
System.out.println("double型的b2:"+b2); //調試時 使 用
if (c.equals("+"))
{
jg2=a2+b2;
}
if (c.equals("-"))
{
jg2=a2-b2;
}
if (c.equals("*"))
{
jg2=a2*b2;
}
if (c.equals("/"))
{
if(b2==0)
{
jg2=0;//0000000000000 by 0 cu!
}
else
{
jg2=a2/b2;
}
}
System.out.println("double型a2"+fh+"b2結果:"+jg2);
System.out.println();
jg=((new Double(jg2)).toString());
jg_TextField.setText(jg);
}
}
}

Ⅵ 用Java設計科學計算器界面 能不能把你做的那個源代碼發給我

package mypackage;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Counter implements ActionListener{
JRadioButton jr1;JRadioButton jr2;JRadioButton jr3;
JButton jbu1;JButton jbu2;JButton jbu3;JButton jbu4;
JButton jbu5;JButton jbu6;JButton jbu7;JButton jbu8;
JButton jbu9;JButton jbu10;JButton jbu11;JButton jbu12;
JButton jbu13;JButton jbu14;JButton jbu15;JButton jbu16;
JFrame fr;
Counter(){
fr=new JFrame("計算器");
}
public void myCounter(JFrame fr){
//獲取內容窗口
Container ctpn = fr.getContentPane();
//設置布局管理器為邊框布局管理器
ctpn.setLayout(new BorderLayout());
//標簽
JPanel panel1=new JPanel();
panel1.setBorder(BorderFactory.createEtchedBorder());
JTextField tfield = new JTextField("",50);
panel1.add(tfield);
ctpn.add(panel1,BorderLayout.NORTH);
//單選按鈕
JPanel panel2=new JPanel(new GridLayout(1,2,10,0));
fr.add(panel2,BorderLayout.CENTER);
panel2.setBorder(BorderFactory.createEtchedBorder());
JPanel panel6=new JPanel();
panel2.add(panel6);
panel6.setBorder(BorderFactory.createEtchedBorder());
panel6.setLayout(new BorderLayout());
JPanel panel3=new JPanel(new GridLayout(1,3));
jr1=new JRadioButton("十進制",true);
jr2=new JRadioButton("八進制");
jr3=new JRadioButton("二進制");
jr1.addActionListener(this);
jr2.addActionListener(this);
jr3.addActionListener(this);
panel3.add(jr3);
panel3.add(jr2);
panel3.add(jr1);
ButtonGroup bg = new ButtonGroup();
bg.add(jr1);
bg.add(jr2);
bg.add(jr3);
panel6.add(panel3,BorderLayout.NORTH);
panel6.setSize(50, 50);
JPanel panel5=new JPanel(new GridLayout(4,4,20,15));
JButton jb1= new JButton("Sin");
JButton jb2= new JButton("And");
JButton jb3= new JButton("(");
JButton jb4= new JButton(")");
JButton jb5= new JButton("Cos");
JButton jb6= new JButton("Or");
JButton jb7= new JButton("Exp");
JButton jb8= new JButton("Ln");
JButton jb9= new JButton("tan");
JButton jb10= new JButton("Xor");
JButton jb11= new JButton("x^y");
JButton jb12= new JButton("log");
JButton jb13= new JButton("e");
JButton jb14= new JButton("Not");
JButton jb15= new JButton("x^3");
JButton jb16= new JButton("n!");
panel5.add(jb1);panel5.add(jb2);panel5.add(jb3);panel5.add(jb4);panel5.add(jb5);
panel5.add(jb6);panel5.add(jb7);panel5.add(jb8);panel5.add(jb9);panel5.add(jb10);
panel5.add(jb11);panel5.add(jb12);panel5.add(jb13);panel5.add(jb14);panel5.add(jb15);
panel5.add(jb16);
panel6.add(panel5,BorderLayout.CENTER);
JPanel panel7=new JPanel();
panel2.add(panel7);
panel7.setBorder(BorderFactory.createEtchedBorder());
panel7.setLayout(new BorderLayout());
JPanel panel4=new JPanel(new GridLayout(1,2));
JCheckBox c1 = new JCheckBox("Inv");
JCheckBox c2 = new JCheckBox("Hyp");
panel4.add(c1);
panel4.add(c2);
panel7.add(panel4,BorderLayout.NORTH);
JPanel panel8=new JPanel(new GridLayout(4,4,20,15));
jbu1= new JButton("0");
jbu2= new JButton("1");
jbu3= new JButton("2");
jbu4= new JButton("3");
jbu5= new JButton("4");
jbu6= new JButton("5");
jbu7= new JButton("6");
jbu8= new JButton("7");
jbu9= new JButton("8");
jbu10= new JButton("9");
jbu11= new JButton("+");
jbu12= new JButton(".");
jbu13= new JButton("*");
jbu14= new JButton("/");
jbu15= new JButton("C");
jbu16= new JButton("=");
panel8.add(jbu1);panel8.add(jbu2);panel8.add(jbu3);panel8.add(jbu4);panel8.add(jbu5);
panel8.add(jbu6);panel8.add(jbu7);panel8.add(jbu8);panel8.add(jbu9);panel8.add(jbu10);
panel8.add(jbu11);panel8.add(jbu12);panel8.add(jbu13);panel8.add(jbu14);panel8.add(jbu15);
panel8.add(jbu16);
panel7.add(panel8,BorderLayout.CENTER);
fr.setSize(600,300);
fr.setLocation(100, 100);
fr.setResizable(false);
fr.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
JRadioButton jr=(JRadioButton)e.getSource();
if(jr==jr1)
{
jbu1.setEnabled(true);jbu2.setEnabled(true);
jbu3.setEnabled(true);jbu4.setEnabled(true);
jbu5.setEnabled(true);jbu6.setEnabled(true);
jbu7.setEnabled(true);jbu8.setEnabled(true);
jbu9.setEnabled(true);jbu10.setEnabled(true);
}
if(jr==jr2)
{
jbu1.setEnabled(true);jbu2.setEnabled(true);
jbu3.setEnabled(true);jbu4.setEnabled(true);
jbu5.setEnabled(true);jbu6.setEnabled(true);
jbu7.setEnabled(true);jbu8.setEnabled(true);
jbu9.setEnabled(false);
jbu10.setEnabled(false);
}
if(jr==jr3)
{
jbu3.setEnabled(false);jbu4.setEnabled(false);
jbu5.setEnabled(false);jbu6.setEnabled(false);
jbu7.setEnabled(false);jbu8.setEnabled(false);
jbu9.setEnabled(false);jbu10.setEnabled(false);
}
}
public static void main(String[] args){
Counter co=new Counter();
JFrame fr=new JFrame("計算器");
co.myCounter(fr);
}
}

Ⅶ 急求C語言編譯的小游戲(如掃雷),附帶源代碼和注釋。

掃雷游戲(c語言版)
已經編譯運行確認了:

#include <graphics.h>
#include <stdlib.h>
#include <dos.h>
#define LEFTPRESS 0xff01
#define LEFTCLICK 0xff10
#define LEFTDRAG 0xff19
#define MOUSEMOVE 0xff08
struct
{
int num;/*格子當前處於什麼狀態,1有雷,0已經顯示過數字或者空白格子*/
int roundnum;/*統計格子周圍有多少雷*/
int flag;/*右鍵按下顯示紅旗的標志,0沒有紅旗標志,1有紅旗標志*/
}Mine[10][10];
int gameAGAIN=0;/*是否重來的變數*/
int gamePLAY=0;/*是否是第一次玩游戲的標志*/
int mineNUM;/*統計處理過的格子數*/
char randmineNUM[3];/*顯示數字的字元串*/
int Keystate;
int MouseExist;
int MouseButton;
int MouseX;
int MouseY;
void Init(void);/*圖形驅動*/
void MouseOn(void);/*滑鼠游標顯示*/
void MouseOff(void);/*滑鼠游標隱藏*/
void MouseSetXY(int,int);/*設置當前位置*/
int LeftPress(void);/*左鍵按下*/
int RightPress(void);/*滑鼠右鍵按下*/
void MouseGetXY(void);/*得到當前位置*/
void Control(void);/*游戲開始,重新,關閉*/
void GameBegain(void);/*游戲開始畫面*/
void DrawSmile(void);/*畫笑臉*/
void DrawRedflag(int,int);/*顯示紅旗*/
void DrawEmpty(int,int,int,int);/*兩種空格子的顯示*/
void GameOver(void);/*游戲結束*/
void GameWin(void);/*顯示勝利*/
int MineStatistics(int,int);/*統計每個格子周圍的雷數*/
int ShowWhite(int,int);/*顯示無雷區的空白部分*/
void GamePlay(void);/*游戲過程*/
void Close(void);/*圖形關閉*/
void main(void)
{
Init();
Control();
Close();
}
void Init(void)/*圖形開始*/
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc");
}
void Close(void)/*圖形關閉*/
{
closegraph();
}
void MouseOn(void)/*滑鼠游標顯示*/
{
_AX=0x01;
geninterrupt(0x33);
}
void MouseOff(void)/*滑鼠游標隱藏*/
{
_AX=0x02;
geninterrupt(0x33);
}
void MouseSetXY(int x,int y)/*設置當前位置*/
{
_CX=x;
_DX=y;
_AX=0x04;
geninterrupt(0x33);
}
int LeftPress(void)/*滑鼠左鍵按下*/
{
_AX=0x03;
geninterrupt(0x33);
return(_BX&1);
}
int RightPress(void)/*滑鼠右鍵按下*/
{
_AX=0x03;
geninterrupt(0x33);
return(_BX&2);
}
void MouseGetXY(void)/*得到當前位置*/
{
_AX=0x03;
geninterrupt(0x33);
MouseX=_CX;
MouseY=_DX;
}
void Control(void)/*游戲開始,重新,關閉*/
{
int gameFLAG=1;/*游戲失敗後判斷是否重新開始的標志*/
while(1)
{
if(gameFLAG)/*游戲失敗後沒判斷出重新開始或者退出遊戲的話就繼續判斷*/
{
GameBegain(); /*游戲初始畫面*/
GamePlay();/*具體游戲*/
if(gameAGAIN==1)/*游戲中重新開始*/
{
gameAGAIN=0;
continue;
}
}
MouseOn();
gameFLAG=0;
if(LeftPress())/*判斷是否重新開始*/
{
MouseGetXY();
if(MouseX>280&&MouseX<300&&MouseY>65&&MouseY<85)
{
gameFLAG=1;
continue;
}
}
if(kbhit())/*判斷是否按鍵退出*/
break;
}
MouseOff();
}
void DrawSmile(void)/*畫笑臉*/
{
setfillstyle(SOLID_FILL,YELLOW);
fillellipse(290,75,10,10);
setcolor(YELLOW);
setfillstyle(SOLID_FILL,BLACK);/*眼睛*/
fillellipse(285,75,2,2);
fillellipse(295,75,2,2);
setcolor(BLACK);/*嘴巴*/
bar(287,80,293,81);
}
void DrawRedflag(int i,int j)/*顯示紅旗*/
{
setcolor(7);
setfillstyle(SOLID_FILL,RED);
bar(198+j*20,95+i*20,198+j*20+5,95+i*20+5);
setcolor(BLACK);
line(198+j*20,95+i*20,198+j*20,95+i*20+10);
}
void DrawEmpty(int i,int j,int mode,int color)/*兩種空格子的顯示*/
{
setcolor(color);
setfillstyle(SOLID_FILL,color);
if(mode==0)/*沒有單擊過的大格子*/
bar(200+j*20-8,100+i*20-8,200+j*20+8,100+i*20+8);
else
if(mode==1)/*單擊過後顯示空白的小格子*/
bar(200+j*20-7,100+i*20-7,200+j*20+7,100+i*20+7);
}
void GameBegain(void)/*游戲開始畫面*/
{
int i,j;
cleardevice();
if(gamePLAY!=1)
{
MouseSetXY(290,70); /*滑鼠一開始的位置,並作為它的初始坐標*/
MouseX=290;
MouseY=70;
}
gamePLAY=1;/*下次按重新開始的話滑鼠不重新初始化*/
mineNUM=0;
setfillstyle(SOLID_FILL,7);
bar(190,60,390,290);
for(i=0;i<10;i++)/*畫格子*/
for(j=0;j<10;j++)
DrawEmpty(i,j,0,8);
setcolor(7);
DrawSmile();/*畫臉*/
randomize();__page_break__
for(i=0;i<10;i++)/*100個格子隨機賦值有沒有地雷*/
for(j=0;j<10;j++)
{
Mine[i][j].num=random(8);/*如果隨機數的結果是1表示這個格子有地雷*/
if(Mine[i][j].num==1)
mineNUM++;/*現有雷數加1*/
else
Mine[i][j].num=2;
Mine[i][j].flag=0;/*表示沒紅旗標志*/
}
sprintf(randmineNUM,"%d",mineNUM); /*顯示這次總共有多少雷數*/
setcolor(1);
settextstyle(0,0,2);
outtextxy(210,70,randmineNUM);
mineNUM=100-mineNUM;/*變數取空白格數量*/
MouseOn();
}
void GameOver(void)/*游戲結束畫面*/
{
int i,j;
setcolor(0);
for(i=0;i<10;i++)
for(j=0;j<10;j++)
if(Mine[i][j].num==1)/*顯示所有的地雷*/
{
DrawEmpty(i,j,0,RED);
setfillstyle(SOLID_FILL,BLACK);
fillellipse(200+j*20,100+i*20,7,7);
}
}
void GameWin(void)/*顯示勝利*/
{
setcolor(11);
settextstyle(0,0,2);
outtextxy(230,30,"YOU WIN!");
}
int MineStatistics(int i,int j)/*統計每個格子周圍的雷數*/
{
int nNUM=0;
if(i==0&&j==0)/*左上角格子的統計*/
{
if(Mine[0][1].num==1)
nNUM++;
if(Mine[1][0].num==1)
nNUM++;
if(Mine[1][1].num==1)
nNUM++;
}
else
if(i==0&&j==9)/*右上角格子的統計*/
{
if(Mine[0][8].num==1)
nNUM++;
if(Mine[1][9].num==1)
nNUM++;
if(Mine[1][8].num==1)
nNUM++;
}
else
if(i==9&&j==0)/*左下角格子的統計*/
{
if(Mine[8][0].num==1)
nNUM++;
if(Mine[9][1].num==1)
nNUM++;
if(Mine[8][1].num==1)
nNUM++;
}
else
if(i==9&&j==9)/*右下角格子的統計*/
{
if(Mine[9][8].num==1)
nNUM++;
if(Mine[8][9].num==1)
nNUM++;
if(Mine[8][8].num==1)
nNUM++;
}
else if(j==0)/*左邊第一列格子的統計*/
{
if(Mine[i][j+1].num==1)
nNUM++;
if(Mine[i+1][j].num==1)
nNUM++;
if(Mine[i-1][j].num==1)
nNUM++;
if(Mine[i-1][j+1].num==1)
nNUM++;
if(Mine[i+1][j+1].num==1)
nNUM++;
}
else if(j==9)/*右邊第一列格子的統計*/
{
if(Mine[i][j-1].num==1)
nNUM++;
if(Mine[i+1][j].num==1)
nNUM++;
if(Mine[i-1][j].num==1)
nNUM++;
if(Mine[i-1][j-1].num==1)
nNUM++;
if(Mine[i+1][j-1].num==1)
nNUM++;
}
else if(i==0)/*第一行格子的統計*/
{
if(Mine[i+1][j].num==1)
nNUM++;
if(Mine[i][j-1].num==1)
nNUM++;
if(Mine[i][j+1].num==1)
nNUM++;
if(Mine[i+1][j-1].num==1)
nNUM++;
if(Mine[i+1][j+1].num==1)
nNUM++;
}
else if(i==9)/*最後一行格子的統計*/
{
if(Mine[i-1][j].num==1)
nNUM++;
if(Mine[i][j-1].num==1)
nNUM++;
if(Mine[i][j+1].num==1)
nNUM++;
if(Mine[i-1][j-1].num==1)
nNUM++;
if(Mine[i-1][j+1].num==1)
nNUM++;
}
else/*普通格子的統計*/
{
if(Mine[i-1][j].num==1)
nNUM++;
if(Mine[i-1][j+1].num==1)
nNUM++;
if(Mine[i][j+1].num==1)
nNUM++;
if(Mine[i+1][j+1].num==1)
nNUM++;
if(Mine[i+1][j].num==1)
nNUM++;
if(Mine[i+1][j-1].num==1)
nNUM++;
if(Mine[i][j-1].num==1)
nNUM++;
if(Mine[i-1][j-1].num==1)
nNUM++;
}__page_break__
return(nNUM);/*把格子周圍一共有多少雷數的統計結果返回*/
}
int ShowWhite(int i,int j)/*顯示無雷區的空白部分*/
{
if(Mine[i][j].flag==1||Mine[i][j].num==0)/*如果有紅旗或該格處理過就不對該格進行任何判斷*/
return;
mineNUM--;/*顯示過數字或者空格的格子就表示多處理了一個格子,當所有格子都處理過了表示勝利*/
if(Mine[i][j].roundnum==0&&Mine[i][j].num!=1)/*顯示空格*/
{
DrawEmpty(i,j,1,7);
Mine[i][j].num=0;
}
else
if(Mine[i][j].roundnum!=0)/*輸出雷數*/
{
DrawEmpty(i,j,0,8);
sprintf(randmineNUM,"%d",Mine[i][j].roundnum);
setcolor(RED);
outtextxy(195+j*20,95+i*20,randmineNUM);
Mine[i][j].num=0;/*已經輸出雷數的格子用0表示已經用過這個格子*/
return ;
}
/*8個方向遞歸顯示所有的空白格子*/
if(i!=0&&Mine[i-1][j].num!=1)
ShowWhite(i-1,j);
if(i!=0&&j!=9&&Mine[i-1][j+1].num!=1)
ShowWhite(i-1,j+1);
if(j!=9&&Mine[i][j+1].num!=1)
ShowWhite(i,j+1);
if(j!=9&&i!=9&&Mine[i+1][j+1].num!=1)
ShowWhite(i+1,j+1);
if(i!=9&&Mine[i+1][j].num!=1)
ShowWhite(i+1,j);
if(i!=9&&j!=0&&Mine[i+1][j-1].num!=1)
ShowWhite(i+1,j-1);
if(j!=0&&Mine[i][j-1].num!=1)
ShowWhite(i,j-1);
if(i!=0&&j!=0&&Mine[i-1][j-1].num!=1)
ShowWhite(i-1,j-1);
}
void GamePlay(void)/*游戲過程*/
{
int i,j,Num;/*Num用來接收統計函數返回一個格子周圍有多少地雷*/
for(i=0;i<10;i++)
for(j=0;j<10;j++)
Mine[i][j].roundnum=MineStatistics(i,j);/*統計每個格子周圍有多少地雷*/
while(!kbhit())
{
if(LeftPress())/*滑鼠左鍵盤按下*/
{
MouseGetXY();
if(MouseX>280&&MouseX<300&&MouseY>65&&MouseY<85)/*重新來*/
{
MouseOff();
gameAGAIN=1;
break;
}
if(MouseX>190&&MouseX<390&&MouseY>90&&MouseY<290)/*當前滑鼠位置在格子范圍內*/
{
j=(MouseX-190)/20;/*x坐標*/
i=(MouseY-90)/20;/*y坐標*/
if(Mine[i][j].flag==1)/*如果格子有紅旗則左鍵無效*/
continue;
if(Mine[i][j].num!=0)/*如果格子沒有處理過*/
{
if(Mine[i][j].num==1)/*滑鼠按下的格子是地雷*/
{
MouseOff();
GameOver();/*游戲失敗*/
break;
}
else/*滑鼠按下的格子不是地雷*/
{
MouseOff();
Num=MineStatistics(i,j);
if(Num==0)/*周圍沒地雷就用遞歸演算法來顯示空白格子*/
ShowWhite(i,j);
else/*按下格子周圍有地雷*/
{
sprintf(randmineNUM,"%d",Num);/*輸出當前格子周圍的雷數*/
setcolor(RED);
outtextxy(195+j*20,95+i*20,randmineNUM);
mineNUM--;
}
MouseOn();
Mine[i][j].num=0;/*點過的格子周圍雷數的數字變為0表示這個格子已經用過*/
if(mineNUM<1)/*勝利了*/
{
GameWin();
break;
}
}
}
}
}
if(RightPress())/*滑鼠右鍵鍵盤按下*/
{
MouseGetXY();
if(MouseX>190&&MouseX<390&&MouseY>90&&MouseY<290)/*當前滑鼠位置在格子范圍內*/
{
j=(MouseX-190)/20;/*x坐標*/
i=(MouseY-90)/20;/*y坐標*/
MouseOff();
if(Mine[i][j].flag==0&&Mine[i][j].num!=0)/*本來沒紅旗現在顯示紅旗*/
{
DrawRedflag(i,j);
Mine[i][j].flag=1;
}
else
if(Mine[i][j].flag==1)/*有紅旗標志再按右鍵就紅旗消失*/
{
DrawEmpty(i,j,0,8);
Mine[i][j].flag=0;
}
}
MouseOn();
sleep(1);
}
}
}

Ⅷ 基於matlab運動模糊圖像處理的源代碼

等一會的,我來幫你

華東師范大學???

tuxianghuanyuan('3.jpg', 80, 8, 0.02);


function tuxianghuanyuan(im, a, b, NSPR)

i = imread(im);

f = im2double(i);

PSF = fspecial('motion', a, b);

frest1 = deconvwnr(f, PSF, NSPR);

subplot(221),imshow(f); title('原圖像');

subplot(222),imshow(frest1); title('維納濾波處理後圖像');

end

閱讀全文

與tanlas源碼相關的資料

熱點內容
查看手機谷歌伺服器地址 瀏覽:191
python操作zookeeper 瀏覽:705
蘋果手機dcim文件夾顯示不出來 瀏覽:430
如何壓縮文件夾聯想電腦 瀏覽:583
程序員的學習之旅 瀏覽:440
apkdb反編譯 瀏覽:922
雪花演算法為什麼要二進制 瀏覽:825
在文檔中打開命令行工具 瀏覽:608
android圖標尺寸規范 瀏覽:369
python實用工具 瀏覽:208
流量計pdf 瀏覽:936
科東加密認證價格 瀏覽:532
dos命令讀文件 瀏覽:996
成為程序員需要什麼學歷 瀏覽:674
pdf農葯 瀏覽:228
canal加密 瀏覽:497
日本安卓系統和中國有什麼區別 瀏覽:137
linux命令行修改文件 瀏覽:838
從編譯和解釋的角度看 瀏覽:650
徐志摩pdf 瀏覽:652