⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 d12r5.cpp

📁 VC++常用数据算法集,里面包含了大量的常用算法程序,很有用的哟!
💻 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 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;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -