码迷,mamicode.com
首页 >  
搜索关键字:for while 列表索引 杨辉三角    ( 29291个结果
质因数的求法
质因数分解 /* 求质因数 */ #include #include int main() { int n,a=2; printf("please input n:"); scanf("%d",&n); if(n<=1) { printf("input error!\n"); return -1; } while(a*a < n) { while(n%a==0) ...
分类:其他好文   时间:2014-05-26 05:50:40    阅读次数:279
c语言快速判断一个数是偶数还是奇数
#include int main() { int a; while(1) { printf("please input the number:\n"); scanf("%d",&a); if(a&1) { printf("%d是奇数\n",a); } else { printf("%d是偶数\n",a); } } return 0; }这...
分类:编程语言   时间:2014-05-26 03:36:15    阅读次数:367
定积分求面积
http://acm.hdu.edu.cn/showproblem.php?pid=1071#include#includeint main(){ //freopen("in.txt","r",stdin); int t; scanf("%d",&t); while(t--)...
分类:其他好文   时间:2014-05-26 02:14:56    阅读次数:222
并行编程之多线程共享非volatile变量,会不会可能导致线程while死循环
背景 大家都知道线程之间共享变量要用volatile关键字。但是,如果不用volatile来标识,会不会导致线程死循环?比如下面的伪代码: static int flag = -1; void thread1(){ while(flag > 0){ //wait or do something } } void thread2(){ //do something f...
分类:编程语言   时间:2014-05-25 10:24:14    阅读次数:220
php -- 连接Mysql 数据库
-----022-mysql.php ----- 1 2 3 4 5 MySQL 6 7 8 MySQL 9 10 mysql_fetch_row查询数据:", "\n";22 while(list($a, $b, $c) = mysql_fetch_row($r...
分类:数据库   时间:2014-05-25 03:24:55    阅读次数:281
Python重写C语言程序100例--Part8
''' 【程序61】 题目:打印出杨辉三角形(要求打印出10行如下图)    1.程序分析: ''' if __name__ == '__main__': a = [] for i in range(10): a.append([]) for j in range(10): a[i].append(0) for i...
分类:编程语言   时间:2014-05-25 00:52:00    阅读次数:436
【练习题】编写打印出一个单链表的所有元素的程序【链表】
只是实现了链表ADT的部分功能。 /*---编写打印出一个单链表的所有元素的程序---*/ #include #include struct Node{ int val; struct Node *next; }; Node *findEnd(Node *list){ while(list->next) list = list->next; return list; } v...
分类:其他好文   时间:2014-05-24 22:30:37    阅读次数:232
从一道面试题(死循环里分配内存)阐述Linux的内存管理
int cnt = 0; while(1) { ++cnt; ptr = (char *)malloc(1024*1024*128); if(ptr == NULL) { printf("%s\n", "is null"); break; } } printf("%d\n", cnt); 这个程序会有怎样的输出呢?...
分类:系统相关   时间:2014-05-24 21:59:47    阅读次数:479
【练习】P62
/*---分别对单链表和双链表,只使用指针来交换两个相邻的元素。---*/ /*-单链表版本-*/ #include #include struct Node{ int val; struct Node *next; }; Node *findEnd(Node *list){ while(list->next) list = list->next; return ...
分类:其他好文   时间:2014-05-24 19:41:49    阅读次数:253
【练习】P62页3.2题
/*---给你一个链表L和另一个链表P,它们包含以升序排列的整数。操作PrintLots(L,P) 将打印L中那些由P所指定位置上的元素。---*/ #include #include struct Node{ int val; struct Node *next; }; Node *findEnd(Node *list){ while(list->next) list = l...
分类:其他好文   时间:2014-05-24 14:27:42    阅读次数:224
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!