码迷,mamicode.com
首页 >  
搜索关键字:while read line for ifs    ( 74720个结果
java每日小算法(6)
/*【程序6】 题目:输入两个正整数m和n,求其最大公约数和最小公倍数。 1.程序分析:利用辗除法。*/ packagetest; publicclasstest{ //最大公约数 publicstaticintcommonisor(intn,intm){ intmax=(n>=m)?n:m; intmin=(n>=m)?m:n; intr=max%min; while(r!=0) { max=min; m..
分类:编程语言   时间:2014-05-27 04:04:03    阅读次数:374
【动态规划初级】 BadNeighbors
目录最大连续序列和不连续序列的最大和1.最大连续序列和是指所有连续子序列元素和最大的那个。#include#includeusing namespace std;int main(){ freopen("in.txt","r",stdin); int n; while(cin>>n) { int a...
分类:其他好文   时间:2014-05-22 11:49:54    阅读次数:273
编程题:输入一串字符,程序会自动将大写字母转换为小写
编程题:输入一串字符,程序会自动将大写字母转换为小写#include<stdio.h>#include<conio.h>main(){ inti=0; chara[50],ch; printf("输入一串字符,程序会自动将大写字母转换为小写\n"); printf("按任意键继续,按Esc键退出\n"); while(ch=getch()!=27) { fflush(..
分类:其他好文   时间:2014-05-21 02:46:26    阅读次数:277
编程题:strcmp()函数的作用是:从左到右逐个字符比较。遇见‘\0’为止。
编程题:strcmp()函数的作用是:从左到右逐个字符比较。(按照字符对应的ascii码值比较)遇见‘\0’为止。#include<stdio.h>#include<string.h>intstring_compare(charstring1[],charstring2[]){inti=0;while(string1[i]==string2[i]&&string1[i]!=‘\0‘)..
分类:其他好文   时间:2014-05-21 01:55:42    阅读次数:368
python的第一个脚本
第一个简单的python脚本#!/usr/bin/python # importos file_1=‘user.txt‘ file_2=‘lock.txt‘ #putanaccount_list f=file(file_1) accout_list=f.readlines() f.close() #putalistofthelockuser f=file(file_2) lock_list=[] foriinf.readlines(): line=i.strip(‘\n‘) lock_list..
分类:编程语言   时间:2014-05-21 01:19:11    阅读次数:391
cocos2d 游戏开发实战
文章转自:http://uliweb.clkg.org/tutorial/read/406cocos2d游戏开发实战6.1创建cocos2d项目6.2cocos2dv3"helloworld"6.2.1显示一个飞船6.3精灵6.4开始spaceviking之旅6.4.1增加sneakyinput6.5精灵的移动效果,旋转效果6.6定时器效果6.7启动cocos2d,默认竖屏6.8检查精灵碰撞参..
分类:其他好文   时间:2014-05-20 23:25:05    阅读次数:363
编程题:用do..while语句实现,求1+2+3+...+100的结果。
编程题:用do..while语句实现,求1+2+3+...+100的结果。#include<stdio.h>voidmain(){ints,n;s=0;n=1;do{s=s+n; n=n+1;}while(n<=100);printf("1+2+3+...+100=%d\n",s);}算法解析图与流程图:do...while语句运行结果:总结:do...while至少执行一次。
分类:其他好文   时间:2014-05-20 19:34:05    阅读次数:294
编程题:用while语句实现,求1+2+...+100的结果。
编程题:用while语句实现,求1+2+...+100的结果。#include<stdio.h>voidmain(){ints,n;s=0;n=1;while(n<=100){ s=s+n;n=n+1;}printf("1+2+3+...+100=%d\n",s);}下面是算法解析与流程图:运行结果:
分类:其他好文   时间:2014-05-20 18:38:34    阅读次数:281
编程题:输入文件名,输出该文件的内容。fgetc(fp)的使用。
编程题:输入文件名,输出该文件的内容。fgetc(fp)的使用。#include<stdio.h>voidmain(){FILE*fp;charout_ch,f_name[30];scanf("%s",f_name);fp=fopen(f_name,"r");if(fp!=NULL){while((out_ch=fgetc(fp))!=EOF)putchar(out_ch);}elseprintf("\n\n\t\t%s文件不存在。\n",..
分类:其他好文   时间:2014-05-20 18:35:52    阅读次数:254
编程题:输入一个数字,实现逆排功能。
编程题:输入一个数字,实现逆排功能。#include<stdio.h>#include<conio.h>fun(intm,char*s){charc;intk,i=10;while(m!=0){k=m%i;*s=k+‘0‘;s++;m=(m-k)/i;}*s=‘\0‘;}main(){intn;chars[81],*p;p=s;printf("enteranumber(>100):");scanf("%d",&n);fun(n,s);p..
分类:其他好文   时间:2014-05-20 17:59:19    阅读次数:232
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!