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

📄 d12r8.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 d12r8
    //driver for routine fourn
	int i,j,k,ndim,ndat,isign,ll;
	double nn[4], data[1025],l;
    ndim = 3;
    ndat = 1024;
    for (i = 1; i<=ndim; i++)
	{
        nn[i] = 2 * pow(2 , i);
    }
    for( i = 1; i<=nn[3]; i++)
	{
        for( j = 1; j<=nn[2]; j++)
		{
            for( k = 1; k<=nn[1]; k++)
			{
              l = k + (j - 1) * nn[1] + (i - 1) * nn[2] * nn[1];
              ll = 2 * l - 1;
              data[ll] = ll;
              data[ll + 1] = ll + 1;
            }
        }
    }
    isign = 1;
    fourn(data, nn, ndim, isign);
    isign = -1;
    cout<<endl<<"Double 3-dimensional transform"<<endl;
    cout<<endl;
    cout<<" Double trabsf.    Original data    ratio"<<endl;
    cout<<endl;
    cout<<" real    imag.   real   imag.   real   imag."<<endl;
    fourn(data, nn, ndim, isign);
    for (i = 1; i<=4; i++)
	{
		cout<<setiosflags(ios::fixed);
        j = 2 * i;
        k = 2 * j;
        l = k + (j - 1) * nn[1] + (i - 1) * nn[2] * nn[1];
        ll = 2 * l - 1;
		cout<<setprecision(2);
        cout<<setw(10)<<(data[ll]);
        cout<<setw(12)<<(data[ll + 1]);
        cout<<setw(8)<<ll;
        cout<<setw(8)<<(ll + 1);
        cout<<setw(10)<<(data[ll] / ll);
        cout<<setw(10)<<(data[ll + 1] / (ll + 1))<<endl;
    }
    cout<<endl;
    cout<<setw(1)<<"the product of transform lengths is: ";
    cout<<setprecision(0)<<setw(3)<<nn[1] * nn[2] * nn[3]<<endl;
}

⌨️ 快捷键说明

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