intest
/*
============================================================================
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的更多相关文章
- INTEST/EXTEST SCAN
INTEST scan指的是对IP 内部的scan cell的扫描测试,针对IP内部的flip-flop进行shift/capture的操作.和INTEST SCAN 对应的就是EXTEST SCAN ...
- INTEST/EXTEST SCAN 的学习
intest scan的一些基本知识.INTEST scan指的是对IP 内部的scan cell的扫描测试,针对IP内部的flip-flop进行shift/capture的操作.和INTEST SC ...
- Enormous Input Test Solved Problem code: INTEST
import sys import psyco #一键优化库 psyco.full() def main(): n, k = map(int, sys.stdin.readline().strip() ...
- 利用epoll写一个"迷你"的网络事件库
epoll是linux下高性能的IO复用技术,是Linux下多路复用IO接口select/poll的增强版本,它能显著提高程序在大量并发连接中只有少量活跃的情况下的系统CPU利用率.另一点原因就是获取 ...
- 在Jena框架下基于MySQL数据库实现本体的存取操作
在Jena框架下基于MySQL数据库实现本体的存取操作 转自:http://blog.csdn.net/jtz_mpp/article/details/6224311 最近在做一个基于本体的管理系统. ...
- JTAG
JTAG是JOINT TEST ACTION GROUP的简称,JTAG的两个标准IEEE 1149.1(2001)和IEEE 1149.7(2009). JTAG中主要包含两部分内容:TAP(TES ...
- 弹出层和ajax数据交互
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs& ...
- 【转】java内部类的作用
http://andy136566.iteye.com/blog/1061951/ 推荐一. 定义 放在一个类的内部的类我们就叫内部类. 二. 作用 1.内部类可以很好的实现隐藏 一般的非内部类,是不 ...
- 基本java类-In.java
package com.algorithm.api; /************************************************************************ ...
随机推荐
- 扩展ASP.NET Identity使用Int做主键
当我们默认新建一个ASP.NET MVC项目的时候,使用的身份认证系统是ASP.NET Identity.但是这里的Identity使用的主键为String类型的GUID.当然这是大多数系统首先类型. ...
- E. Binary Numbers AND Sum
链接 [http://codeforces.com/contest/1066/problem/E] 题意 给你长度分别为n,m的二进制串,当b>0时,对a,b,&运算,然后b右移一位,把 ...
- sring引入mybatis
1.首先框架结构是这样的(jar包还是要导的) 2.web.xml和springMVC-servlet.xml未作任何新的配置,这里简单贴一下代码: <?xml version="1. ...
- 【Deep Hash】NINH
[CVPR 2015] Simultaneous Feature Learning and Hash Coding with Deep Neural Networks [paper] Hanjiang ...
- EasyUI treegrid 模糊查询、搜索
纯JS完成 treegrid 模糊搜索功能: $("#dataTab").treegrid({ url: '/Organization/GetOrganizationList', ...
- [系统软件]Ubuntu 18.04中的Shutter禁用了“编辑”选项解决
本文引用自linux公社, 原文请点击 : https://www.linuxidc.com/Linux/2018-04/151911.htm 在Ubuntu 18.04中安装了我最喜欢的截图工具 ...
- Spring Cloud 路由网关服务端
修改application.properties配置文件:服务端口号.本机名称: 启动注册中心:java -jar uap-register-server-1.0.jar --spring.confi ...
- solt插槽的使用。
在组件内template中使用 <slot name='header'></slot> 在页面内 直接添加标签 如 <hs><h1 slot='header' ...
- ACM数论之旅12---康托展开((*゚▽゚*)装甲展开,主推进器启动,倒计时3,2,1......)
在我们做题中,搜索也好,动态规划也好,我们往往有时候需要用一个数字表示一种状态 比如有8个灯泡排成一排,如果你用0和1表示灯泡的发光情况 那么一排灯泡就可以转换为一个二进制数字了 比如 0110011 ...
- python之unittest单元测试
# unittest单元测试 import unittest from class_demo import Car class TestCar(unittest.TestCase): '''测试Car ...