#include <stdio.h>
#include <stdlib.h>int main()
{
int sign = 1;
double deno = 2.0;
double sum = 1.0;
double result = 0;
while (deno <= 100)
{
sign = (-1)*sign;
result = sign / deno;
sum = sum + result;
deno = deno + 1;
}
printf("%f\n", sum);
system("pause");
return 0;
}原文:http://10919090.blog.51cto.com/10909090/1719851
题目:输入三个整数i,j,k,请把这三个数由小到大输出。 1 #include<stdio.h>2 3int main(void){4int i,j,k;5 scanf("%d %d %d",&i,&j,&k);6if(i>j){7int temp=0;8 temp=i;9 i=j;
10 j=temp;
11 }
12if(i>k){
13int temp=0;
14 temp=i;
15 i=k;
16 k=temp;
17 }
1819if(j>k){
20int temp=0;
21 temp=j;
22 ...
笔者阅览过网上许多的推荐,基本上都是推荐cl命令,但是因为笔者是通过dev c++入门的,不想放弃dev所以就强行使用dev来实现在dos下的编译以及运行
编译
注意:这边涉及到环境变量的配置,环境变量相当于每次在当前目录的时候编译的时候都可以访问到的其他目录的位置,因为本来计算机只能访问当前目录下所有的文件,而环境变量的使得计算机可以访问其他目录下的文件
这里需要找到gcc.exe文件,一般是在Dev-Cpp\MinGW64\bin,当然前面...
如果程序里面有错误,希望大家能够批评指正!#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<time.h>
#define WIN 256 // 可以修改决定游戏输赢的值// 矩阵数组
int num[4][4]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int t[5]={0,0,0,0,0}; // 辅助数组
int move=0; // 记录移动步数
int score=0; // 记录得分情况
int max=0; // max表示游戏输赢,max=WIN时赢
int change=1;
// 产生一个随机位置和随机数
vo...
#include<stdio.h>
int main()
{int a=15;printf("%#x\n",a);return0;}
/*output 0xf;
*///(15)10= (f)16
//#x的作用是把一个数用16进制表示出来#include<stdio.h>
int main()
{int a;printf("%d\n",a);return0;
}
/*output 0
*///变量为什么要初始化 原文:http://www.cnblogs.com/renchong/p/5287481.html
#include <stdio.h>struct student{int num;char name[40];int computer, english, math;double average;
};int main(void){int i, index, j ,n;struct student students[50], temp;printf("Input n:");scanf("%d", &n);for (i = 0; i < n; i++) {printf("Input the info of No.%d:\n", i+1);printf("number:");scanf("%d", &students[i].num);printf("name:");scanf("%s", students[i].name);printf("math score:");scanf("%d", &...
编译多个C源代码文件 当程序文件越来越多,修改了其中的一部分代码文件,我们并不需要全部重新编译,只需要编译其中一部分就可以,下面我们创建了一个launch程序,除了主程序,我们创建了3个功能代码文件reaction.c pitch.c engine.c1 #include <stdio.h>
2 #include "lac.h"34void reaction(){
5 printf("reaction \n");
6 }1 #include <stdio.h>
2 #include "lac.h"34void pitch(){
5 printf("pitch \n");
6 }1 #incl...
#include<stdio.h>
#include<stdlib.h>void printMatrix(int **matrix,int columns,int rows,int start)
{int x=columns-start-1;int y=rows-start-1;int i;for(i=start;i<=x;i++)//先打印一行printf("%d ",matrix[start][i]);if(start<y)//从上往下{for(i=start+1;i<=y;i++)printf("%d ",matrix[i][x]);}if(x>start&&y>start)//从右到左打印{for(i=x-1;i>=start;i--)printf("%d ",matrix[y][i]);}if(x>start&&y>start+1)//从下到上...
文件操作常用函数fopen() 打开流
fclose() 关闭流
fputc() 写一个字符到流中
fgetc() 从流中读一个字符
fseek() 在流中定位到指定的字符
fputs() 写字符串到流
fgets() 从流中读一行或指定个字符
fprintf() 按格式输出到流
fscanf() 从流中按格式读取
feof() 到达文件尾时返回真值
ferror() 发生错误时返回其值
rewind() 复位文件定位器到文件开始处
remove() 删除文件
fread() 从流中读指定个数的字符
fwrite() 向流中...
今天发布源代码,由于写在一个文件里非常乱,所以分三个文件写绘图和鼠标函数graph.h/*绘图与鼠标相关函数*/#include<graphics.h>
#include <easyx.h>void DrawEmpty(int, int, int, int);//初始化空格子界面的函数
void DrawSmile(void);//画笑脸的函数
void DrawRedFlag(int, int);//右键画红旗的函数
int MouseX, MouseY;//鼠标的x,y坐标
MOUSEMSG m;//鼠标结构变量,接受鼠标消息void DrawSmile(void)
{setfillstyle(BS_SOLID)...
把做工程过程经常用的内容记录起来,如下内容段是关于C语言多种方法求解字符串编辑距离问题的内容。{ if(xbeg > xend) { if(ybeg > yend) return 0; else return yend - ybeg + 1; } if(ybeg > yend) { if(xbeg > xend) return 0; else return xend - xbeg + 1; } if(ptrX[xend] == ptrY[yend]) { return calDistance1(p...
阅读优秀代码是提高开发人员修为的一种捷径…… 1. Webbench Webbench是一个在linux下使用的非常简单的网站压测工具。它使用fork()模拟多个客户端同时访问我们设定的URL,测试网站在压力下工作的性能,最多可以模拟3万个并发连接去测试网站的负载能力。Webbench使用C语言编写, 代码实在太简洁,源码加起来不到600行。下载链接:http://home.tiscali.cz/~cz210552/webbench.html 2. Tinyhttpd tinyhtt...
【C语言】关于解决scanf函数调用中的恶意输入/无效输入导致bug问题以及代码实现自动化解决解析
这里输代码:
#include <stdio.h>int FormatInput(char opt);int FormatInput(char opt)
{while (1){if (opt == 'Y' || opt == 'N'){if(opt == 'Y'){return 1;break;}else{printf("\n\n\n\n\n\n");return 0;break;}}else{while(getchar() != 10);// delete meaningless stringsprintf ("\n=============================\n INVAL...
Java支持本地语言代码,这是否意味着我可以使用java程序执行C语言代码.如果是,则这将是机器相关代码或机器独立代码,并且JVM对Java代码应用了许多与安全相关的限制,因此它们是否会影响C语言中的代码?JVM应用的限制是否也适用于Native C语言代码?解决方法:是的,该项目将取决于机器.如果本机库/代码无法通过该JVM链接(例如,如果您有Windows JVM和ELF / .so库,或32位JVM和64位库),则System.loadLibrary(String )将因UnsatisfiedLinkEr...
我花了很多时间在运行Ubuntu Linux(11.04)的机器上设置CUDA工具链.该装备有两个NVIDIA Tesla GPU,我可以从NVIDIA GPU计算SDK编译和运行测试程序,如deviceQuery,deviceQueryDrv和bandwidthTest.
当我尝试从书籍和在线资源中编译基本样本程序时,我的问题出现了.我知道你应该用NVCC编译,但每当我使用它时我都会遇到编译错误.基本上任何涉及CUDA库的include语句都会丢失文件/库错误.一个例子是:#include <cutil.h>我是否需要某种makef...