随笔分类 -  c++基础知识

C++中,get getline gets 用法
摘要:1、cin 2、cin.get() 3、cin.getline() 4、getline() 5、gets() 6、getchar() 1、cin>> 用法1:最基本,也是最常用的用法,输入一个数字: #include <iostream> using namespace std; main () { 阅读全文

posted @ 2020-10-03 10:29 财盛 阅读(413) 评论(0) 推荐(0)

bits/stdc++.h
摘要:// C++ includes used for precompiling -*- C++ -*- // Copyright (C) 2003-2014 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ 阅读全文

posted @ 2020-08-17 10:01 财盛 阅读(333) 评论(0) 推荐(0)

函数和方法的讲解
摘要:函数(function)的函代表信函,即联结、关联的意思,用于编程则代表一个变量(或数值)的变化会引起其他变量以及结果的变化,如x=3,y=2x,那么y的值就是6,当x的值改成4,y的值就是8;这种运算方式也形象地称为方法。数学上的函数的定义是自变量a的值发生变化时,因变量b也会有一个变化后的对应值 阅读全文

posted @ 2020-08-17 09:27 财盛 阅读(522) 评论(0) 推荐(0)

20200807求梯形面积,要求输入浮点数,输出精度为2位
摘要:#include <bits/stdc++.h>#include <iomanip> //precision要用using namespace std;double a,b,c,d;int main(){ cin>>a>>b>>c; d=(a+b)*c/2; // printf("%.2lf",d) 阅读全文

posted @ 2020-08-07 20:06 财盛 阅读(258) 评论(0) 推荐(0)

c++语言printf()输出格式大全 scanf()输入格式大全
摘要:1.转换说明符 %a(%A) 浮点数、十六进制数字和p-(P-)记数法(C99) %c 字符 %d 有符号十进制整数 %f 浮点数(包括float和doulbe) %e(%E) 浮点数指数输出[e-(E-)记数法] 1.23E+10,即 1.23 乘以 10 的 10 次幂 %g(%G) 根据数值不 阅读全文

posted @ 2020-08-04 19:49 财盛 阅读(4959) 评论(0) 推荐(0)

202007XX 结果保留到小数后2位
摘要:# include <iostream># include <iomanip> //manipulator 操控者using namespace std;int main(){ int a,b; cin>>a>>b; int c=a/b; cout<<c<<endl; double e=a,f=b; 阅读全文

posted @ 2020-07-27 19:56 财盛 阅读(130) 评论(1) 推荐(0)

202006XX b=++a 和b=a++区别
摘要:举例: b=++a: a=1 ,++a后 a=2,b=2; b=a++: a=1,b=a所以b=1, a++后,a=2,b=1; 阅读全文

posted @ 2020-06-17 21:00 财盛 阅读(356) 评论(0) 推荐(0)

20191208-while +if
摘要:#include "stdafx.h" #include "iostream" #include "string" using namespace std; int main() { int line=0; char ch; while (cin.get(ch)) { if(ch=='Q'){bre 阅读全文

posted @ 2020-05-21 10:20 财盛 阅读(106) 评论(0) 推荐(0)

20191208-对一个整数开方,不能用sqrt
摘要:要求:对70开方,保留到小数后1位。 #include "stdafx.h" #include "iostream" #include "string"#include "iomanip" using namespace std; int main() { int a=70; double b=0; 阅读全文

posted @ 2020-05-21 10:18 财盛 阅读(286) 评论(0) 推荐(0)

函数和结构2
摘要:#include "stdafx.h" #include "iostream" #include "cmath" using namespace std; struct polar {double distance;double angle;}; struct rect {double x;doub 阅读全文

posted @ 2020-05-21 10:16 财盛 阅读(163) 评论(0) 推荐(0)

函数和结构
摘要:代码部分: #include "stdafx.h" #include "iostream" struct travel_time {int hours;int mins;}; const int Mins_per_hr=60; travel_time sum( travel_time t1,trav 阅读全文

posted @ 2020-05-21 10:14 财盛 阅读(173) 评论(0) 推荐(0)

ASCII码及核心单词
摘要: 阅读全文

posted @ 2020-05-21 10:04 财盛 阅读(243) 评论(0) 推荐(0)

c++判断与推理
摘要:#include<iostream> using namespace std; int main() { string mm,md; cout<<"一口咬掉牛尾巴(打一字),请猜:"<<endl; cin>>md; if (md=="告") cout<<"正确"; else cout<<"错了"; 阅读全文

posted @ 2020-05-20 16:06 财盛 阅读(499) 评论(0) 推荐(0)