随笔分类 -  C++

摘要:1. char数组: 使用scanf("%[^c]",s)可以以c字符为间隔读取字符串。 所以scanf("%[^\n]",s)可以以读取以换行符为间隔读取字符串。 但是它不会吃掉换行符,所以scanf连着用时要用getchar()把中间的换行符吃掉才行。 2. string 使用getline(c 阅读全文
posted @ 2020-03-14 11:46 Frank__Chen 阅读(2493) 评论(0) 推荐(1)
摘要:使用:io>>x>>y; 即可 阅读全文
posted @ 2019-07-28 22:06 Frank__Chen 阅读(306) 评论(0) 推荐(0)
摘要:0. 在有些输入数据很多的变态题中,scanf会大大拖慢程序的时间,cin就更慢了,所以就出现了读入优化。其原理就是一个一个字符的读入,输出优化同理,主要使用getchar,putchar函数。 1. int型读入优化(long long的只要把x改成long long型即可): 2.double型 阅读全文
posted @ 2019-04-06 12:13 Frank__Chen 阅读(395) 评论(0) 推荐(0)
摘要:#include #include #include using namespace std; const int maxlen=1000; typedef struct node{ //工作记录结点 int adr; //返址 int np; char xp,yp,zp; //值参 }snode; typedef... 阅读全文
posted @ 2018-11-01 10:45 Frank__Chen 阅读(236) 评论(0) 推荐(1)
摘要:#include #include #define LEN sizeof(PolyNode) typedef struct node{ //声明多项式节点的结构体表示 float coef; //系数 int exp; //指数 struct node* next; }PolyNode; //多项式节点 typedef PolyN... 阅读全文
posted @ 2018-11-01 10:42 Frank__Chen 阅读(472) 评论(0) 推荐(0)