⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 total.c

📁 linux下的C语言开发
💻 C
字号:
/*-*//******************************************************** * Program:						* *	Total						* *							* * Purpose:						* *	Compute the total of a list of numbers.		* *							* * Usage:						* *	Run the program.  Type in the numbers one at a	* *	time.  When you reach the end, type a 0 to	* *	exit the program.				* ********************************************************//*+*/#include <stdio.h>char  line[100];/* line of data for input */int   total;  	/* Running total of all numbers so far */int   item;   	/* next item to add to the list */int main(){    total = 0;    while (1) {        printf("Enter # to add \n");        printf("  or 0 to stop:");        fgets(line, sizeof(line), stdin);        sscanf(line, "%d", &item);        if (item == 0)            break;        total += item;        printf("Total: %d\n", total);    }    printf("Final total %d\n", total);    return (0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -