20191208-while +if

  1. #include "stdafx.h"

  2. #include "iostream"

  3. #include "string"

  4. using namespace std;

  5. int main()

  6. { int line=0;

  7.   char ch;

  8.   while (cin.get(ch))

  9.   {

  10.   if(ch=='Q'){break;}

  11.   if(ch!='\n'){continue;}   

  12.   }

  13. }

 

程序思路:第11号可有可无。

下一组代码:

  1. #include "stdafx.h"

  2. #include "iostream"

  3. #include "string"

  4. using namespace std;

  5. inline double square(double x){return x*x;}

  6. int main()

  7.   double a,b;

  8.   double c=13.0;

  9.   a=square(5.0);

  10.   b=square(4.5+7.5);

  11.   cout<<"a="<<a<<endl;

  12.   cout<<"b="<<b<<endl;

  13.   cout<<square(c++)<<endl;

  14.   cout<<"c="<<c<<endl;

  15.  

  16. }

运行结果:

 

 
posted @ 2020-05-21 10:20  财盛  阅读(99)  评论(0编辑  收藏  举报