这段源码能在linux下运行!!! 能识别小数
#include<unistd.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
/*#define NULL 0*/
/* 自定义变量 */
#define sy_if 0
#define sy_then 1
#define sy_else 2
#define sy_while 3
#define sy_begin 4
#define sy_do 5
#define sy_end 6
#define a 7
#define semicolon 8
#define e 9
#define jinghao & ......
int svd(int m,int n,int withu,int withv,double eps,double tol,
double *a, double *q, double *u, double *v, double *vt)
{
int i,j,k,l,l1,iter,retval;
double c,f,g,h,s,x,y,z;
double *e;
e = (double *)calloc(n,sizeof(double));
retval = 0;
/* Copy 'a' to 'u' */
for (i=0;i<m;i++) {
for (j=0;j<n;j++)
u[i*n + j] = a[i*n + j];
}
/* Householder's reduction to bidiagonal form. */
g = x = 0.0;
for (i=0;i<n;i++) {
e[i] = g;
s = 0.0;
l = i+1;
for (j=i;j<m;j++)
s += (u[j*n+i]*u[j*n+i]);
if (s < tol)
g = 0.0;
else {
f = u[i*n+i];
g = (f < 0) ? sqrt(s) : -sqrt(s);
h = f * g - s;
u[i*n+i] = f - g;
for (j=l;j< ......
In C++, how do i go about using setenv to set the display? I need to set it like this:
export DISPLAY=0.0
1、setenv("DISPLAY",":0.1",1);
If you're calling the xrandr functions from your C++ program, then I would expect setenv() should work for you. The 3rd argument of 1 tells setenv() to overwrite any previous value of argument 1 (DISPLAY). You'd be out of luck if xrandr cached the display name though. In that case, you'd have to re-invoke a program from a shell script: the shell script could set the DISPLAY each time before starting your program. That would be less C++ coding
#include <stdlib.h>
#include <stdio.h>
int main(){
char *env1 = getenv("test11");
printf("test11=%s\n", env1); //show current env variable
setenv("test11","abcd",1); //reset it
env1 = getenv("test11");
printf("test11=%s\n", env1);
//this value reset is gone after the program finished
return 0;
}
g++ setenv.cpp -o mysetenv ......
In C++, how do i go about using setenv to set the display? I need to set it like this:
export DISPLAY=0.0
1、setenv("DISPLAY",":0.1",1);
If you're calling the xrandr functions from your C++ program, then I would expect setenv() should work for you. The 3rd argument of 1 tells setenv() to overwrite any previous value of argument 1 (DISPLAY). You'd be out of luck if xrandr cached the display name though. In that case, you'd have to re-invoke a program from a shell script: the shell script could set the DISPLAY each time before starting your program. That would be less C++ coding
#include <stdlib.h>
#include <stdio.h>
int main(){
char *env1 = getenv("test11");
printf("test11=%s\n", env1); //show current env variable
setenv("test11","abcd",1); //reset it
env1 = getenv("test11");
printf("test11=%s\n", env1);
//this value reset is gone after the program finished
return 0;
}
g++ setenv.cpp -o mysetenv ......
C语言,有时候真不得不佩它,照理说,文件处理函数是没有什么好讲的,但对于很多C入门的人来说,似乎也是值得静心品味一番的。
C中的文件处理函数并不很多,而常用的,似乎更少。
函数不难,但并不代表文件处理也不难。似乎又要有点跑题了,我总是喜欢跑题。上几天做梦,梦到我掉到月球上去啦……
对文件的操作,无非就是打开、读写、调整读写偏移指针以及关闭,似乎么什可说的,也许事实也的确如此。还是让我们来看一段经典代码吧,这代码可是我自己写的。
FILE* fp = fopen(”test.txt”, “r”); assert(fp); //打开文件,给一个断言,这是一种好习惯
fseek(fp, 0, SEEK_END); //把偏移指针指向文件的结尾
unsigned int nlen = ftell(fp); //返回当前的偏移指针,也就是返回刚刚设定的文尾位置
fseek(fp, 0, SEEK_SET); //把读写偏移指针指向文件的开头
char* const _psz = (char*)malloc(nlen + 1);
//申请一段堆内存,这里的_psz为什么要被const修饰呢?
unsigned int size = fread(_psz, sizeof(char), nlen, fp); //读出文件的内容
_psz[size] = ‘\0′; //注意,必须要在字符串的结尾处添加结束标志,否则, ......
问题描述:
C#程序,里面copy了许多原来的代码,所以参差不齐的,很难读,如何才能让代码自动排齐,就象VS 6.0中可以使用快捷键,非常方便.
解答:
ctrl+a,先全选
ctrl+k,ctrl+f,自动排列
或者
ctrl+a,先全选
alt+F8 自动排列 ......
问题描述:
C#程序,里面copy了许多原来的代码,所以参差不齐的,很难读,如何才能让代码自动排齐,就象VS 6.0中可以使用快捷键,非常方便.
解答:
ctrl+a,先全选
ctrl+k,ctrl+f,自动排列
或者
ctrl+a,先全选
alt+F8 自动排列 ......
问题描述:
C#程序,里面copy了许多原来的代码,所以参差不齐的,很难读,如何才能让代码自动排齐,就象VS 6.0中可以使用快捷键,非常方便.
解答:
ctrl+a,先全选
ctrl+k,ctrl+f,自动排列
或者
ctrl+a,先全选
alt+F8 自动排列 ......
开始—运行—gpedit.msc,打开组策略窗口—用户配置下的“管理模板”—WINDOWS组件,双击打开Windows资源管理器,然后双击“防止从我的电脑访问驱动器”,打开“属性”窗口,选择“已启用”,然后选择“仅限制驱动器C”(你可以把你不想让别人打开的驱动盘都限制,呵呵),OK,完成 ......