求序列和的简单C程序
对于序列求和的程序大家不会陌生,而我今天看到的这个程序个人觉得比较好,所以贴上来共享一下。
要求:输入类似于87 98 67 56 0的任意序列,但是以零结尾。然后输出序列的和。
程序如下 :
/********************************************
* Name : sum.c
* Purpose : sum
* Author : zimo
* Date : 01/21/2010
* *****************************************/
#include <stdio.h>
int main(void)
{
int n , sum = 0;
printf("This program sums a series of integers. \n");
printf("Enter integers (0 to terminate): ");
scanf("%d", &n);
while(n != 0)
{
sum += n;
scanf("%d", &n);
}
printf("The sum is: %d \n", sum);
return 0;
}
两次的输入语句个人觉得非常好。(所输入的序列要求必须是最后一个数为零,当然也可以简单的修改)
相关文档:
#include <assert.h> //设定插入点
#include <ctype.h> //字符处理
#include <errno.h> //定义错误码
#include <float.h> //浮点数处理
#include <fstream.h> //文件输入/输出
#include <iomanip.h> //参数化输入/输出
#include & ......
1.开发工具下载
TUBER C http://www.duote.com/soft/392.html
Turbo C 2.0 汉化版 http://www.programfan.com/showdown.asp?id=306
C-Free 4.0 http:/ ......
Google Android开发博客今天宣布,即日起开放针对Android平台的原生软件开发SDK下载。由于在SDK前面又加上了原生二字,即Native Development Kit,因此又被Google称为NDK。在此之前,Android平台的第三方应用程序均是依靠基于Java的Dalvik特制虚拟机进行开发的。原生 SDK的公布可以让开发者更加直接的接触Android系统资源, ......
一.环境的安装
下载安装包,Google上搜索php+apache+sql的安装包并安装。
二.扩展编程
针对在PHP环境下掉用C编程(c程序编译的dll),主要有以下两种方式。
1.利用ATL构建DLL组件,然后再PHP里面直接调用,调用方法 ......
找错题
试题1:
void test1()
{
char string[10];
char* str1 = "0123456789";
strcpy( string, str1 );
}
试题2:
void test2()
{
char string[10], str1[10];
int i;
for(i=0; i<10; i++)
{
str1[i] = 'a';
}
strcpy( string, str1 );
}
试题3:
void test3( ......