/*
============================================================================
Name : http.c
Author :
Version :
Copyright : Your copyright notice
Description : Hello World in C, Ansi-style
============================================================================
*/

#include <stdio.h>
#include <stdlib.h>
#if 0
#include <stdio.h>
#include <curl/curl.h>

/*
char data[100];
data[0] = '\0'; //BUILD DATA STRING FOR XML REQUEST
strcat(data, "id=");
strcat(data, id);
strcat(data, "&");
strcat(data, "function=");
strcat(data, function);
strcat(data, "&");
strcat(data, "parameter=");
strcat(data, parameter);
*/

char unitid[] = "TEST05";
char buff[51200];

size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream)
{

char * pbuf = &buff[0];

memset(buff, '\0', size*nmemb+1);
size_t i = 0;
for(; i < nmemb ; i++){
strncpy(pbuf,ptr,size);
pbuf += size;
ptr += size;
}
printf("XML:\n %s\n",buff);

return size * nmemb;
}

void post_reporting(char *unit_id, int media_id, long time_played, int male0, int male1, int male2, int male3, int female0, int female1, int female2, int female3, int unknown)
{
char data[100];
char temp_char[11];

data[0] = '\0';
strcat(data, "function=P&P=");
itoa(media_id,temp_char);
strcat(data, temp_char);

strcat(data, "&T=");
itoa(time_played,temp_char);
strcat(data, temp_char);

strcat(data, "&R=");
itoa(male0,temp_char); //convert child male
strcat(data, temp_char); //join to data string
strcat(data, ","); //CSV input
itoa(male1,temp_char); //convert young male
strcat(data, temp_char); //join to data string
strcat(data, ","); //CSV input
itoa(male2,temp_char); //convert adult male
strcat(data, temp_char); //join to data string
strcat(data, ","); //CSV input
itoa(male3,temp_char); //convert senior male
strcat(data, temp_char); //join to data string
strcat(data, ","); //CSV input
itoa(female0,temp_char); //convert child female
strcat(data, temp_char); //join to data string
strcat(data, ","); //CSV input
itoa(female1,temp_char); //convert young female
strcat(data, temp_char); //join to data string
strcat(data, ","); //CSV input
itoa(female2,temp_char); //convert adult female
strcat(data, temp_char); //join to data string
strcat(data, ","); //CSV input
itoa(female3,temp_char); //convert senior male
strcat(data, temp_char); //join to data string
strcat(data, ","); //CSV input
itoa(unknown,temp_char); //convert unknow audience
strcat(data, temp_char); //join to data string

strcat(data, "&id="); //CSV input
strcat(data, unit_id); //CSV input
strcat(data, "&debug=1"); //DEBUG

printf("data:%s\n", data);

CURL *curl;
CURLcode res;

/* In windows, this will init the winsock stuff */
curl_global_init(CURL_GLOBAL_ALL);

/* get a curl handle */
curl = curl_easy_init();
if(curl) {
/* First set the URL that is about to receive our POST. This URL can
just as well be a https:// URL if that is what should receive the
data. */
curl_easy_setopt(curl, CURLOPT_URL, "http://192.168.1.200:8888/cms/trunk/update.php");
/* Now specify the POST data */
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &write_data); //put returned data in to memory

/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));

/* always cleanup */
curl_easy_cleanup(curl);
}
curl_global_cleanup();

printf("stuff in memory: \n%s\n",buff);
}

void post_powerup(char *unit_id)
{
char data[100];
char temp_char[11];

data[0] = '\0';
strcat(data, "function=1&id=");
strcat(data, unit_id);

CURL *curl;
CURLcode res;

/* In windows, this will init the winsock stuff */
curl_global_init(CURL_GLOBAL_ALL);

/* get a curl handle */
curl = curl_easy_init();
if(curl) {
/* First set the URL that is about to receive our POST. This URL can
just as well be a https:// URL if that is what should receive the
data. */
curl_easy_setopt(curl, CURLOPT_URL, "http://192.168.1.200:8888/cms/trunk/update.php");
/* Now specify the POST data */
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &write_data); //put returned data in to memory

/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));

/* always cleanup */
curl_easy_cleanup(curl);
}
curl_global_cleanup();

printf("stuff in memory: \n%s\n",buff);

}

/* BEGIN itoa.c */

void itoa(int, char *);
char *sput_i(int, char *);
char *sput_ip1(int, char *);

void itoa(int integer, char *string)
{
if (0 > integer) {
++integer;
*string++ = '-';
*sput_ip1(-integer, string) = '\0';
} else {
*sput_i(integer, string) = '\0';
}
}

char *sput_i(int integer, char *string)
{
if (integer / 10 != 0) {
string = sput_i(integer / 10, string);
}
*string++ = (char)('0' + integer % 10);
return string;
}

char *sput_ip1(int integer, char *string)
{
int digit;

digit = (integer % 10 + 1) % 10;
if (integer / 10 != 0) {
string = (digit == 0 ? sput_ip1 : sput_i)(integer / 10, string);
*string++ = (char)('0' + digit);
} else {
if (digit == 0) {
*string++ = '1';
}
*string++ = (char)('0' + digit);
}
return string;
}

/* END itoa.c */

int main(void)
{
post_powerup(unitid);

post_reporting(unitid, 377, 1348304373, 0, 1, 2, 3, 0, 1, 2, 3, 10);
return 0;
}
#endif

int main(){
monthly();
}

int monthly(){
int total = 240;//months

float intest_day = 1.83f;
float base = 705000.00f;
float rate = 0.052;

int i=0;
float sum=base;
for(;i<total;i++){
int bak=sum;
sum+=sum*rate/12;
printf("intest month %d; sum: %10.2f intest: %10.2f\n",i,sum, sum-bak);
// if(i%12==0){
// printf("\t\year %d:%10.2f", i/12,sum-base);
// }
}

printf("\n total intest: %f",sum-base);

// printf("Year rate: %10.2f", (sum-base)/base);
return 0;
}

int daily(void)
{

float intest_day = 1.83f;
float base = 14420.00f;
float rate = 1.83f/base;

int i=0;
float sum=base;
for(;i<365;i++){
sum+=sum*rate;
printf("%d : %10.2f\n",i,sum);
if(i%30==0){
printf("\t\tmonth %d:%10.2f", i/30,sum-base);
}
}

printf("\n Year: %f",sum-base);

printf("Year rate: %10.2f", (sum-base)/base);
return 0;
}

intest的更多相关文章

  1. INTEST/EXTEST SCAN

    INTEST scan指的是对IP 内部的scan cell的扫描测试,针对IP内部的flip-flop进行shift/capture的操作.和INTEST SCAN 对应的就是EXTEST SCAN ...

  2. INTEST/EXTEST SCAN 的学习

    intest scan的一些基本知识.INTEST scan指的是对IP 内部的scan cell的扫描测试,针对IP内部的flip-flop进行shift/capture的操作.和INTEST SC ...

  3. Enormous Input Test Solved Problem code: INTEST

    import sys import psyco #一键优化库 psyco.full() def main(): n, k = map(int, sys.stdin.readline().strip() ...

  4. 利用epoll写一个"迷你"的网络事件库

    epoll是linux下高性能的IO复用技术,是Linux下多路复用IO接口select/poll的增强版本,它能显著提高程序在大量并发连接中只有少量活跃的情况下的系统CPU利用率.另一点原因就是获取 ...

  5. 在Jena框架下基于MySQL数据库实现本体的存取操作

    在Jena框架下基于MySQL数据库实现本体的存取操作 转自:http://blog.csdn.net/jtz_mpp/article/details/6224311 最近在做一个基于本体的管理系统. ...

  6. JTAG

    JTAG是JOINT TEST ACTION GROUP的简称,JTAG的两个标准IEEE 1149.1(2001)和IEEE 1149.7(2009). JTAG中主要包含两部分内容:TAP(TES ...

  7. 弹出层和ajax数据交互

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs& ...

  8. 【转】java内部类的作用

    http://andy136566.iteye.com/blog/1061951/ 推荐一. 定义 放在一个类的内部的类我们就叫内部类. 二. 作用 1.内部类可以很好的实现隐藏 一般的非内部类,是不 ...

  9. 基本java类-In.java

    package com.algorithm.api; /************************************************************************ ...

随机推荐

  1. 生成线上用https证书,支持通配符和多域名,初学Let’s Encrypt用于IIS,纯本地手动

    自简书发布的上篇<生成本地测试用https证书,支持通配符和多域名,初学OpenSSL>以来,本地测试用https用的妥妥的. 线上一直用的腾讯云的免费证书(每个域名都要一个证书(滑稽), ...

  2. 归并排序O(nlogn)

    先分治再合并 代码 #include<bits/stdc++.h> using namespace std; #define ll long long int a[1000],t[1000 ...

  3. 对PS的评价

    Photoshop(简称:PS)是电脑上的图像处理软件:对于广大Photoshop爱好者而言,PS亦用来形容通过该类图形处理软件处理过的图片,即非原始.非未处理的图片:多数人对于这软件的了解仅限于“一 ...

  4. 12.15 Daily Scrum

      Today's Task Tomorrow's Task 丁辛 实现和菜谱相关的餐厅列表. 实现和菜谱相关的餐厅列表.             邓亚梅             美化搜索框UI. 美 ...

  5. Linux实践四:ELF文件格式分析

    一.分析ELF文件头 二.通过文件头找到section header table,理解内容 三.通过section header table 找到各section 四.理解常见.text .strta ...

  6. 小学四则运算APP 第二阶段冲刺-第五天

    团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第二次冲刺阶段时间:11.29~12.09 本次发布的是判断题代码,已经实现部分功能,,但是美中不足的是判断错误 panduanset.j ...

  7. A glance for agile method

    看看Apache最新的JIRA,新版的JIRA是有Agile模块的. Scrum早有耳闻,接触得也比较多,Kanban一次面试中提到过.今日深入查阅KanBan: http://www.agilewe ...

  8. msyql sql语句收集

    在不断的学习中,发现了一些新的slq语句,总结于此. 一.复制数据表的sql 1)create table tableName  as  select  * from   tableName2     ...

  9. Angular require(抄别的)

    require参数的值可以用下面的前缀进行修饰,这会改变查找控制器时的行为:?如果在当前指令中没有找到所需要的控制器,会将null作为传给link函数的第四个参数.^如果添加了^前缀,指令会在上游的指 ...

  10. poj 2762(强连通分量+拓扑排序)

    题目链接:http://poj.org/problem?id=2762 题意:给出一个有向图,判断任意的两个顶点(u,v)能否从u到达v,或v到达u,即单连通,输出Yes或No. 分析:对于同一个强连 ...