?? d12r5.cpp
字號(hào):
#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 d12r5
//driver for routine cosft
int i,np,npp2,nlim,j,temp,temp1;
double data[17],eps,width1,per,big,small,scal1;
const double pi = 3.14159;
temp=1;
temp1=-1;
eps = 0.001;
np = 16;
npp2 = np + 2;
width1 = 30.0;
cout<<endl;
cout<<"Period of sinusoid in channels (2-"<<np<<")"<<endl;
per = 16;
cout<<per<<endl;
if (per <= 0.0)
exit(1);
for (i = 1; i<=np; i++)
{
data[i] = cos(2.0 * pi * (i - 1) / per);
}
cosft(data, np,temp);
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;
}
cosft(data, np,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;
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -