?? d12r4.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 d12r4
//driver for routine sinft
int i,np,npp2,n,nlim,j;
double data[17],eps,width1,per,big,small,scal1;
eps = 0.001;
np = 16;
npp2 = np + 2;
width1 = 30.0;
const double pi = 3.14159;
n = np / 2;
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] = sin(2.0 * pi * (i - 1) / per);
}
sinft(data, np);
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;
}
sinft(data, np);
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 + -