Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  1
Language: C/C++
Code:
/***********************************************************************************************************************
Includes
***********************************************************************************************************************/
#include <stdio.h>
#include <stdlib.h>
/***********************************************************************************************************************
Global variables and functions 全局变量和函数
***********************************************************************************************************************/
unsigned char R_Remainder,R_Business,R_Heating_Time;
unsigned char R_Interval_Value,R_Period_Time;
unsigned char R_Insert_Value,R_Period_Value;
unsigned char R_Negate;
/***********************************************************************************************************************
*功能名称:Heating_Parameter_Set
*说明    :设置周期和点数
*参数    :unsigned char Time,unsigned char值
*返回值  :无
***********************************************************************************************************************/
void Heating_Parameter_Set(unsigned char Time,unsigned char Value)
{
     R_Heating_Time = Time - 1;
     if(Value>Time) Value=Time;
     if(Value<Time&&Value)
     {
         if(Time>(2*Value))
         {
             R_Remainder = Time%Value;
             R_Business = Time/Value;
             R_Negate = 0;
         }
         else
         {
            R_Remainder = Time%(Time - Value);
             R_Business = Time/(Time - Value);
             R_Negate = 1;
         }
     }
     else if(Value==Time&&Value)
     {
        R_Remainder = 0;
         R_Business = 1;         
     }
     else R_Business = 0;
}
/***********************************************************************************************************************
*函数名称:Temperature_Control_Output
*说明    :均匀程序
*参数    :无
*返回值  :无
***********************************************************************************************************************/
char Temperature_Control_Output(void)
{
    if(R_Business)
    {
         if(R_Period_Time>R_Heating_Time)
         {
              R_Period_Time = 0;
              R_Interval_Value = 0;
              R_Insert_Value = R_Remainder;
              R_Period_Value = R_Business;
         }
         if(!R_Period_Time)
         {
            R_Period_Time = 0;
             R_Interval_Value = 0;
             R_Insert_Value = R_Remainder;
             R_Period_Value = R_Business;             
         }
         if(!R_Interval_Value)
         {
             if(!R_Negate) printf("+");
             else printf("-");
              R_Period_Time++; 
              if(R_Insert_Value)
              {
                   R_Interval_Value = R_Period_Value;
                   R_Insert_Value--;
              }
              else R_Interval_Value = R_Period_Value - 1;
         }
         else 
         {
             if(!R_Negate) printf("-");
             else printf("+");
             R_Period_Time++; 
              R_Interval_Value--;
         }
    }
    else return 1;
}
/***********************************************************************************************************************
*功能名称:主函数
*说明    :无
*参数    :无
*返回值  :无
***********************************************************************************************************************/
int main(void)
{
    unsigned char x,i,j;
    for(j=0;j<11;j++)
    {
        Heating_Parameter_Set(10,j);
        for(x=0;x<10;x++)
        {
            i = Temperature_Control_Output();
        }
        if(i) printf("无");
        printf("n");
    }
     return EXIT_SUCCESS;
}
          
Comments: