Arnold圖像變換算法

// 08C.cpp : Defines the entry point for the console application.
//[email protected]
//

#include "stdafx.h"
#include<stdio.h>
#include<stdlib.h>


int _tmain(int argc, _TCHAR* argv[])
{
int circle(int scalar);
int n,i,number=0,array[10];
scanf_s("%d",&n);
while(n)
{
array[number++]=n;
scanf_s("%d",&n);
}
for(i=0;i<number;i++)
{
printf("%d\n",circle(array[i]));//處理數據存放在函數中,而在輸出語句中使用調用了原始數據並處理之後的結果
}
system("pause");
return 0;
}
//circle:計算週期T
int circle(int scalar)
{
int newi=0,newj=1,oldi,oldj;
int t=1;
oldi=(newi+newj)%scalar;
oldj=(newi+2*newj)%scalar;
while(!(oldi==newi&&oldj==newj))
{
int temp;
temp=oldi;
oldi=(oldi+oldj)%scalar;
oldj=(temp+2*oldj)%scalar;
t++;
}
if(scalar>2&&t<scalar*scalar/2)
return t;
else
return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章