码迷,mamicode.com
首页 >  
搜索关键字:for while until    ( 29426个结果
read函数返回值始终为1
部分程序如下:while(count=read(fd_s,buf,512)>0)printf("count=%d\n",count);write(fd_d,buf,count);打印出来的count始终1,原因:运算符优先级的问题。改为:while((count=read(fd_s,buf,512)...
分类:其他好文   时间:2014-07-14 14:54:25    阅读次数:194
将标准输入复制到标准输出
mycat/mycat.c 1 #include "apue.h" 2 #define BUFFSIZE 4096 3 int 4 main(void) 5 { 6 int n; 7 char buf[BUFFSIZE]; 8 while ((...
分类:其他好文   时间:2014-07-14 14:38:27    阅读次数:161
寻找房间中心zz
Finding the Centroid of a Room Boundary It's been a while since my last post and I'm sure most of you were like... "Where the hell is Don!".... it's o...
分类:其他好文   时间:2014-07-14 10:35:17    阅读次数:247
字符串匹配算法
字符串朴素匹配法相等情况int index(const char * str1, const char * str2, int pos){ int i = pos; int j = 0; while(i = strlen(str2)) // matched and retu...
分类:其他好文   时间:2014-07-14 09:00:51    阅读次数:176
uva11388
#includeusing namespace std;int main(){ int g,l,t; cin>>t; while(t--){ cin>>g>>l; if(l%g==0)//最大公约数一定是最小公倍数的因子 cout ...
分类:其他好文   时间:2014-07-13 21:34:46    阅读次数:176
hdu 2021 发工资咯:)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2021题目大意:给老师发工资,找出最少的人民币张数。 1 #include 2 int main () 3 { 4 int a,n,i,sum; 5 while (scanf("%d",...
分类:其他好文   时间:2014-07-13 20:30:07    阅读次数:162
Swift编程语言——循环(for 、 while)
Swift提供了类似 C 语言的流程控制结构,包括可以多次执行任务的for和while循环,基于特定条件选择执行不同代码分支的if和switch语句,还有控制流程跳转到其他代码的break和continue语句。   除了 C 语言里面传统的for条件递增(for-condition-increment)循环,Swift 还增加了for-in循环,用来更简单地遍历数组(array),字典(di...
分类:编程语言   时间:2014-07-13 16:50:21    阅读次数:279
Java语言的基础知识3
第四章1、sum+=x++;的语句等价于sum=sum+x;和x=x+1;两条语句2、do....while循环语句与while循环语句类似。他们之间的差别是while语句为先判断条件是否成立再执行循环体,而do...while循环语句是先执行一次循环体,在判断条件是否成立。也就是说do....while循环语句至少执行一次..
分类:编程语言   时间:2014-07-13 14:18:10    阅读次数:216
[华为机试]求出数组中所有奇数之和以及所有偶数之和
代码: #include #include #include #include int main() { int num[100]; int odd = 0, even = 0; std::string str; getline(std::cin, str); std::stringstream s(str); int j = 0; while(getline(s, s...
分类:其他好文   时间:2014-07-13 13:54:31    阅读次数:280
c语言输入数据
比如要求输入一行数据(注意:没有给出输入多少个),并且以空格隔开那么就可以如下进行判断1 char c='0';2 int a[10],temp,i=0;3 while(c!='\n')4 {5 scanf("%d%c",&temp,&c);6 a[i]=temp;7 i++; ...
分类:编程语言   时间:2014-07-13 13:10:53    阅读次数:231
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!