一、数据的输入与输出 1.stdio.h中包含的函数: getchar(输入字符) gets(输入字符串) printf(格式输出) putchar(输出字符) puts(输出字符串) scanf(格式输入) flushall(刷新缓冲区) 等等 2.flushall(); ...
分类:
编程语言 时间:
2015-02-04 09:23:16
阅读次数:
233
本来是当做水题来做的,后来发现这道题略坑。首先输入的字符串可能是空串,所以我用了gets函数,紧接着就被scanf("%d", &n)后面的换行符坑掉了。于是乎再加一句getchar() 1 #include 2 #include 3 #include 4 using namespace st...
分类:
其他好文 时间:
2015-02-04 00:27:19
阅读次数:
331
题解:dpDescriptionAlex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game a...
分类:
其他好文 时间:
2015-02-03 22:37:26
阅读次数:
104
斯坦福大学机器学习公开课:Programming Exercise 2: Logistic Regression---Matlab实现
1 Logistic Regression
In this part of the exercise, you will build a logistic regression model to predict whether astudent gets...
分类:
其他好文 时间:
2015-02-03 21:22:42
阅读次数:
1109
scanf(), getchar()等都是标准输入函数,一般人都会觉得这几个函数非常简单,没什么特殊的。但是有时候却就是因为使用这些函数除了问题,却找不出其中的原因。下面先看一个很简单的程序:
程序1:
#include
int main()
{
char ch1, ch2;
scanf("%c", &ch1);
scanf("%c", &ch2);
printf("%d %d...
分类:
其他好文 时间:
2015-01-30 16:14:27
阅读次数:
136
#1094 : Lost in the City时间限制:10000ms单点时限:1000ms内存限制:256MB描述Little Hi gets lost in the city. He does not know where he is. He does not know which direc...
分类:
其他好文 时间:
2015-01-30 10:39:24
阅读次数:
225
【题意】:很普通的解码问题,所有的大写字母左移5位。注意A-E的移动是加21,其他的减5。
【代码:AC】
#include
#include
#include
#include
#include
using namespace std;
#define MAX 200+10
int main()
{
char str[MAX];
while (gets(str))...
分类:
其他好文 时间:
2015-01-30 00:05:37
阅读次数:
184
题目:acm.hust.edu.cn/vjudge/roblem/viewProblem.action?id=19191这道题本身难度不大,但输入输出时需要特别小心,一不留神就会出问题。对于输入,如果要读入一行时:没有空白字符,则直接使用scanf和%s即可;有空白字符,使用gets,但要小心溢出;...
分类:
其他好文 时间:
2015-01-27 21:38:27
阅读次数:
186
1. 假设*p=a[20]; p[i]---表示a[i]; p+i---表示a[i]的地址2. 用scanf()函数输入中间不能有空格;否则要用gets()函数(只能有一个参数)3. 指向二维数组a[4][5]的*p,如果要表示a[i][j]则需要写成*(p+i*5+j)4. 用指针表示二维...
分类:
其他好文 时间:
2015-01-26 20:48:34
阅读次数:
170
#include
#include
int main()
{
int n;
int i,j;
char a[4];
int t;
char m;
scanf("%d",&n);getchar();
while(n--)
{
gets(a);
j=strlen...
分类:
其他好文 时间:
2015-01-25 18:19:48
阅读次数:
156