?? d12r3.cpp
字號:
#include <iostream.h>
#include <math.h>
#include <iomanip.h>
#include <stdlib.h>
#include <fstream.h>
#include <string>
#include <process.h>
#include<stdio.h>
void main()
{
//program d12r3
//driver for routine realft
int i,np,npp2,n,temp,j,temp1;
double data[35], size1[33],eps,width1,per,big,small,scal1,nlim;
temp=1;
temp1=-1;
eps = 0.001;
np = 32;
npp2 = np + 2;
width1 = 50.0;
const double pi = 3.14159;
n = np / 2;
cout<<setw(1)<<"period of sinusoid in channels (2-"<<endl;
cout<<"; or 0 to stop)"<<endl;
per = 32;
if (per <= 0.0)
exit(1);
for (i = 1; i<=np; i++)
{
data[i] = cos(2.0 * pi * (i - 1) / per);
}
realft(data, n, temp);
big = -10000000000.0;
for( i = 1; i<=n; i++)
{
size1[i]=sqrt(data[2*i-1]*data[2*i-1]+data[2*i]*data[2*i]);
if (i == 1)
size1[i] = data[i];
if (size1[i] > big )
big = size1[i];
}
scal1 = width1 / big;
for (i = 1; i<=n; i++)
{
nlim = scal1 * size1[i] + eps;
cout<<setw(4)<<i<<" ";
for (j = 1; j<=nlim + 1; j++)
{
cout<<"*";
}
cout<<endl;
}
realft(data, n, temp1);
big = -10000000000.0;
small = 10000000000.0;
for (i = 1;i<=np;i++)
{
if (data[i] < small)
small = data[i];
if (data[i] > big)
big = data[i];
}
scal1 = width1 / (big - small);
for (i = 1; i<=np; i++)
{
nlim = int(scal1 * (data[i] - small) + eps);
cout<<setw(4)<<i<<" ";
for (j = 1; j<=nlim + 1; j++)
{
cout<<"*";
}
cout<<endl;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -