`
- 浏览:
197430 次
- 性别:
- 来自:
重庆
-
- int strlen(char s[])
- {
- int i;
- while (s[i] != '\0')
- ++i;
- return i;
- }
-
- int strlen(char *s)
- {
- int n;
- for (n = 0; *s != '\0', s++)
- n++;
- return n;
- }
- void strcpy(char *s, char *t)
- {
- int i;
- i = 0;
- while ((s[i] = t[i]) != '\0')
- i++;
- }
-
- void strcpy(char *s, char *t)
- {
- int i;
- i = 0;
- while ((*s = *t) != '\0') {
- s++;
- t++;
- }
- }
- void strcpy(char *s, char *t)
- {
- while ((*s++ = *t++) != '\0')
- ;
- }
- int strcmp(char *s, char *t)
- {
- int i;
- for (i = 0; s[i] == t[i]; i++)
- if (s[i] == '\0')
- return 0;
- return s[i] - t[i];
- }
-
- int strcmp(char *s, char *t)
- {
- for ( ; *s == *t; s++, t++)
- if (*s == '\0')
- return 0;
- return *s - *t;
- }
- void squeeze(char s[], int c)
- {
- int i, j;
- for (i = j = 0; s[i] != '\0'; i++)
- if (s[i] != c)
- s[j++] = s[i];
- s[j] = '\0';
- }
- void strcat(char s[], char t[])
- {
- int i, j;
- i = j = 0;
- while (s[i] != '\0')
- i++;
- while ((s[i++] = t[j++]) != '\0')
- ;
- }
-
- unsigned getbits(unsigned x, int p, int n)
- {
- return (x >> (p+1-n)) & ~(~0 << n);
- }
- int binsearch(int x, int v[], int n)
- {
- int low, high, mid;
- low = 0;
- high = n - 1;
- while (low <= high) {
- mid = (low+high)/2;
- if (x < v[mid])
- high = mid + 1;
- else if (x > v[mid])
- low = mid + 1;
- else
- return mid;
- }
- return -1;
- }
- #include <ctype.h>
-
- int atoi(char s[])
- {
- int i, n, sign;
- for (i = 0; isspace(s[i]); i++)
- ;
- sign = (s[i] == '-') ? -1 : 1;
- if (s[i] == '+' || s[i] == '-')
- i++;
- for (n = 0; isdigit(s[i]); i++)
- n = 10 * n + (s[i] - '0');
- return sign * n;
- }
- void shellsort(int v[], int n)
- {
- int gap, i, j, temp;
- for (gap = n/2; gap > 0; gap /= 2)
- for (i = gap; i < n; i++)
- for (j=i-gap; j>=0 && v[j]>v[j+gap]; j-=gap) {
- temp = v[j];
- v[j] = v[j+gap];
- v[j+gap] = temp;
- }
- }
- #include <string.h>
-
- void reverse(char s[])
- {
- int c, i, j;
- for (i = 0, j = strlen(s)-1; i < j; i++, j--) {
- c = s[i];
- s[i] = s[j];
- s[j] = c;
- }
- }
-
- void itoa(int n, char s[])
- {
- int i, sign;
- if ((sign = n) < 0)
- n = -n;
- i = 0;
- do {
- s[i++] = n % 10 + '0';
- } while ((n /= 10) > 0);
- if (sign < 0)
- s[i++] = '-';
- s[i] = '\0';
- reverse(s);
- }
- #include <ctype.h>
-
- double atof(char s[])
- {
- double val, power;
- int i, sign;
- for (i = 0; isspace(s[i]); i++)
- ;
- sign = (s[i] == '-') ? -1 : 1;
- if (s[i] == '+' || s[i] == '-')
- i++;
- for (val = 0.0; isdigit(s[i]); i++)
- val = 10.0 * val + (s[i] - '0');
- if (s[i] == '.')
- i++;
- for (power = 1.0; isdigit(s[i]); i++) {
- val = 10.0 * val + (s[i] - '0');
- power *= 10;
- }
- return sign * val / power;
- }
-
- void qsort(int v[], int left, int right)
- {
- int i, last;
- void swap(int v[], int i, int j);
- if (left >= right)
- return;
- swap(v, left, (left + right)/2);
- last = left;
- for (i = left + 1; i <= right; i++)
- if (v[i] < v[left])
- swap(v, ++last, i);
- swap(v, left, last);
- qsort(v, left, last-1);
- qsort(v, last+1, right);
- }
-
- void swap(int v[], int i, int j)
- {
- int temp;
- temp = v[i];
- v[i] = v[j];
- v[j] = temp;
- }
-
- int trim(char s[])
- {
- int n;
- for (n = strlen(s)-1; n >= 0; n--)
- if (s[n] != ' ' && s[n] != '\t' && s[n] != '\n')
- break;
- s[n+1] = '\0';
- return n;
- }
- void itob(int n, char s[], int b)
- {
- int i = 0, j , sign;
- if( ( sign = n ) < 0 )
- n = - n;
-
- do
- {
- j = n % b;
- s[i++] = ( j <= 9 )?j+'0':j-10+'a';
- }while( ( n/=b ) > 0 );
- if( sign < 0 )
- s[i++]='-';
- s[i] = '\0';
- reverse(s);
- }
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
单片机C语言中code的作用 单片机C语言中code的作用
C语言 实现的一维码CODE128编码算法
有很多经典、简易的代码,包括汉字库代码,和点阵字代码
行列式计算程序 c语言 code:block通过 先输入阶数 读c盘根目录c:\in.txt 先输入阶数
3rd Generation Partnership Project; Technical Specification Group Services and System Aspects; Speech codec speech processing functions; Adaptive Multi-Rate - Wideband (AMR-WB) ...ANSI-C code (Release 9)
C&C++ code C&C++ code C&C++ code C&C++ code C&C++ code
C语言头文件 RETCODEC语言头文件 RETCODEC语言头文件 RETCODEC语言头文件 RETCODEC语言头文件 RETCODEC语言头文件 RETCODEC语言头文件 RETCODEC语言头文件 RETCODEC语言头文件 RETCODEC语言头文件 RETCODEC语言...
关于C语言简单程序的编写,以及一些作业题目的答案。
C语言27-I2C从机中断模式与IO口模拟I2C主机进行自发自收(STC32G-DEMO-CODE-220311kw)C语言27-I2C从机中断模式与IO口模拟I2C主机进行自发自收(STC32G-DEMO-CODE-220311kw)C语言27-I2C从机中断模式与IO口模拟I2C...
php codephp codephp codephp codephp codephp codephp codephp code
This reference describes the C and C++ computer programming ...CodeWarrior C and C++ compilers. It covers specific information that applies to the CodeWarrior implementations of the C and C++ languages.
专业CAN工具VehicleSpy 3的二次开发,讲解用C调用接口实现自动化编程测试
C语言28-I2C主机模式访问AT24C02程序(STC32G-DEMO-CODE-220311kw)C语言28-I2C主机模式访问AT24C02程序(STC32G-DEMO-CODE-220311kw)C语言28-I2C主机模式访问AT24C02程序(STC32G-DEMO-CODE-220311kw)C语言28-I2C...
C语言44-高级PWM输出两路互补SPWM(STC32G-DEMO-CODE-220311kw)C语言44-高级PWM输出两路互补SPWM(STC32G-DEMO-CODE-220311kw)C语言44-高级PWM输出两路互补SPWM(STC32G-DEMO-CODE-220311kw)C语言44-高级PWM输出...
Java code Java code Java code Java code Java code Java code Java code
C语言STC32G-BOARD-220311(STC32G-DEMO-CODE-220311kw)C语言STC32G-BOARD-220311(STC32G-DEMO-CODE-220311kw)C语言STC32G-BOARD-220311(STC32G-DEMO-CODE-220311kw)C语言STC32G-BOARD-220311(STC32G-DEMO-...