码迷,mamicode.com
首页 >  
搜索关键字:eof    ( 7139个结果
键盘接收字符,如果是大写,则输出小写;是小写,则输出大写;是数字则不输出
#include<stdio.h>#include<stdlib.h>intmain(){intch;while((ch=getchar())!=EOF)if(ch>=65&&ch<=95){ch+=32;putchar(ch);printf("\n");}else{ch-=32;putchar(ch);printf("\n");}}
分类:其他好文   时间:2015-09-29 15:01:37    阅读次数:222
【C语言】接收字符,大小写字符相互转换后输出,数字不输出
#include<stdio.h> #include<stdlib.h> voidmain() { intch; while((ch=getchar())!=EOF) if(ch>=65&&ch<=95) { ch+=32; putchar(ch); } else { ch-=32; putchar(ch); } }
分类:编程语言   时间:2015-09-29 01:21:01    阅读次数:198
只打印最长的一行及其长度
//从标准输入输入几行,并计算出它们的长度(包括\n),打印出最长的一行及其长度#include<stdio.h>#include<process.h>intmain(){ intch=0; inti=0; intj=0; intk=0; intarr[1000]={0}; intarr0[1000]={0}; intcount=0; intmax_count=0; while((ch=getchar())!=EOF..
分类:其他好文   时间:2015-09-26 01:52:05    阅读次数:207
从标准输入读取C源代码,并验证所有的花括号都正确的成对出现
#include<stdio.h>#include<process.h>intmain(){ charc=0; intcount=0; while((c=getchar())!=EOF) { if(c==‘{‘) { count++; } elseif(c==‘}‘&&count==0) { printf("花括号不匹配!"); return0; } elseif(c==‘}‘&&count!=0) { co..
分类:其他好文   时间:2015-09-21 19:45:03    阅读次数:153
标志位也很重要哦!
//从标准输入读取几行输入。每行输入都要打印到标准输出上,前面加上行号。//在编写这个程序的时候要使这个程序能够处理的输入行的长度没有限制。#include<stdio.h>#include<process.h>intmain(){intc=0;intline=1;intflag=1;while((c=getchar())!=EOF){while(flag..
分类:其他好文   时间:2015-09-21 19:41:08    阅读次数:185
C++ Primer
再次重温下C++ Primer 第一章、开始 1、GNU编译器使用g++ $ g++ -o prog1 prog1.cc 2、 while(std::cin >> value) 使用一个istream作为条件时,如果遇到Eof,或无效输入(不匹配类型)则判断为假,跳出 第二章:变量和基本类型 一、基...
分类:编程语言   时间:2015-09-20 22:19:18    阅读次数:164
编写一个程序,它从标准输入读取C源代码,并验证所有的花括号都正确的成对出现
(三种if的情况考虑完整,注意解决问题的思想)#include<stdio.h>intmain(){intcount=0;charch;while((ch=getchar())!=EOF)//直到出现文件结束标志,不再进入循环{if(ch==‘{‘){count++;}if(ch==‘}‘&&count==0)//前无‘{‘,而后有‘}‘,即不匹配{printf("不匹配\n");r..
分类:其他好文   时间:2015-09-19 22:48:57    阅读次数:264
SSH免密码登陆脚本
#!/bin/bash #?for?self?configure ? wd=.__tmp__sfsfas mkdir?-p?$wd ? hosts=(172.172.177.23?172.172.17.24?172.172.177.25) ? for?i?in?"${hosts[@]}" do ??script=$(cat?<<?\EOF ??s...
分类:其他好文   时间:2015-09-19 12:33:15    阅读次数:170
cin.ignore()的用法 cin.clear() cin.setstate()
cin.ignore()basic_istream&ignore(streamsize_Count=1,int_type_Delim=traits_type::eof());function:Causesanumberofelementstobeskippedfromthecurrentreadpo...
分类:其他好文   时间:2015-09-18 13:47:36    阅读次数:315
C语言中的getchar和putchar详解
首先给出《The_C_Programming_Language》这本书中的例子:#includeintmain(){intc;c =getchar();while(c!=EOF){putchar();c=getchar();}return0;}这里主要解释下为什么要用int型来接受getchar函数...
分类:编程语言   时间:2015-09-18 11:56:52    阅读次数:155
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!