1. 求一元二次方程ax² + bx + c = 0的解  a,b,c为任意整数。(10分)
    2. 编写一个口令输入程序,让用户不停输入口令,直到输对为止,假设口令为456。(8分)
    3. 输出1000-9999之间能对3整除的回文数。(8分)
    4. (10分)

      定义一个结构体变量(包括年,月,日),计算该日在本年中是第几天(规定一月一日为第一天)。(10分)

    5. 读入一个正整数 n(小于100),计算其各位数字之和,用汉语拼音写出和的每一位数字。
      ​  输入:
                94
          输出(每位数字中间加一个空格):
                yi san  /*(13)*/
      汉语拼音如下:(0:ling , 1:yi , 2:er , 3:san , 4:si , 5:wu ,
      6:liu , 7:qi , 8:ba , 9:jiu)。(14分)
    6. 定义一个函数swap在swap函数的功能是将a 和 b的值进行交换,在主函数中先输出交换前的值,再输出交换后的值(用指针做)。(6分)
    7. 输入十个整数,在函数fun()中将其排序为由小到大,在主函数中输出排序后的结果。
      (10分)
    8. 编写一个函数fun()输出得到的字符串的长度和字符串的倒序(不能用String.h里的函数)。
      (12分)
    9. 有一分数序列:2/1,3/2,5/3,8/5,13/8,21/13...求出这个数列的前20项之和(结果保留两位小数)。(12分)
    10. #include<stdlib.h>
      #include<stdio.h>
      #include<iostream>
      using namespace std; int main()
      {
      int a, b, c;
      double decide, x1, x2, m, n;
      cout << "求一元二次方程的解" << endl << "请输入系数a,b,c(用空格隔开)"<<endl;
      cin >> a >> b >> c;
      decide = (double)b * (double)b - * (double)a * (double)c;
      if (decide < )
      {
      printf("当前方程无解 \n");
      }
      else if (decide < )
      {
      m = -b / ( * a);
      n = sqrt(decide) / ( * (double)a);
      x1 = m + n;
      cout << "当前一元二次方程有两个相同的解" << x1;
      }
      else if(decide >)
      {
      m = -b / ( * a);
      n = sqrt(decide) / ( * (double)a);
      x1 = m + n;
      x2 = m - n;
      printf("一元二次方程的解是:\nx1=%.2f\nx2=%.2f\n", x1, x2);
      system("pause");
      }
      return ;
      }
      #include<iostream>
      #include<stdlib.h>
      #include<stdio.h>
      using namespace std; int main()
      {
      int b;
      cout << "请输入口令\n";
      while ()
      {
      cin >> b;
      if (b == )
      {
      break;
      }
      else
      {
      cout << "输入错误,请再来一次\n";
      }
      }
      system("color 02");
      cout << "输入正确";
      }
      #include<iostream>
      #include<stdlib.h>
      #include<stdio.h>
      using namespace std; int main()
      {
      cout << "这个程序将输出000-9999之间能对3整除的回文数";
      int a, i = ;
      for(a=;a<;a++)
      {
      if(a/==a/% && a/%==a/% && a%==)
      {
      cout << i;
      printf("%5d\n", a);
      i++;
      }
      }
      }
      #include<stdlib.h>
      #include<stdio.h>
      #include<iostream>
      using namespace std; float chufa(int n)
      {
      float sum ;
      sum = 1.0;
      int m=;
      for (int i = ; i <= n; i++)
      {
      m = m + i;
      }
      sum = sum / m;
      return sum;
      } int main()
      {
      int m,s=;
      float summary=;
      cin >> m;
      for (s; s <= m; s++)
      {
      summary = chufa(s)+summary;
      }
      cout << summary;
      return ;
      }
      #include<iostream>
      #include<stdio.h>
      #include<cmath>
      using namespace std; /*定义一个结构体变量(包括年,月,日),计算该日在本年中是第几天(规定一月一日为第一天)。(10分)*/
      struct book
      {
      int year=;
      int month;
      int day;
      };
      int main()
      {
      struct book a;
      int n;
      cout << "请输入月和日" << endl;
      cin >> a.month >> a.day;
      if (a.month < || a.month>)
      {
      cout << "月份输入错误\n";
      }
      if (a.day < || a.day>)
      {
      cout << "日子输入错误\n";
      }
      if (a.month > && a.month < && a.day> && a.day < )
      {
      n = a.day + * a.month;
      cout << "这是一年中的第" << n << "天" << endl;
      }
      else
      {
      cout << "数据输入有误,请再次输入";
      }
      return ;
      }
      #include<stdlib.h>
      #include<string.h>
      #include<stdio.h>
      #include<iostream>
      using namespace std; int main(void)
      {
      int s,a,b,c,m,n,sum;
      const char r[][] = { "ling","yi","er","san","si","wu","liu","qi","ba","jiu" };
      cout << "请输入一个小于100的正整数"<<endl;
      cin >> s;
      if (s > && s < )
      {
      a=s/;
      b = s % ;
      sum = a + b;
      m = sum / ;
      n = sum % ;
      cout << r[m] <<" "<<r[n];
      }
      else
      {
      cout << "请输入正确的数字";
      } return ;
      }
      #include<iostream>
      #include<stdlib.h>
      #include<stdio.h>
      using namespace std; void swap_s(int * pa, int* pb)
      {
      int t = *pa;
      * pa = *pb;
      * pb = t;
      } int main()
      {
      int a , b ;
      int a1, b1;
      cout << "此程序将a 和 b的值进行交换,<<endl<<先输出交换前的值,再输出交换后的值"<<endl;
      cout << "请输入a b(用空格隔开)"<<endl;
      cin >> a >> b;
      a1 = a;
      b1 = b;
      swap_s(&a, &b);
      cout << a1 << " " << b1 << endl;
      cout << a <<" "<< b<<endl;
      return ;
      }
      #include<stdlib.h>
      #include<stdio.h>
      #include<iostream>
      using namespace std; void fun()
      {
      int a[];
      cout << "请输入10个整数(用空格隔开)" << endl;
      for (int u = ; u <= ; u++)
      {
      cin >> a[u];
      }
      int i, j;
      int temp;
      cout << "从小到大排序"<<endl;
      int n = ;
      for (i = ; i < n;i++)
      {
      for (j = n - ; j > i; j--)//第一次循环是针对于a[9]的排序,以此类推
      {
      if (a[j - ] < a[j])
      {
      temp = a[j - ];
      a[j - ] = a[j];
      a[j] = temp;
      }
      }
      }
      for (int w = ; w >= ; w--)
      {
      cout << a[w]<<endl;
      }
      } int main(void)
      {
      fun();
      return ;
      }
      #include<stdlib.h>
      #include<stdio.h>
      #include<iostream>
      using namespace std; //void fun(char *a)
      void fun(char a[])
      {
      int m, i;
      for (m = ; m < ; m++)
      {
      if (a[m] == '\0')
      {
      cout << "字符串的长度为:" << m + << endl;
      break;
      }
      }
      for (i = m - ; i >= ; i--)
      {
      cout << a[i];
      }
      } int main()
      {
      char a[];
      cout << "请输入字符串"<<endl;
      cin >> a;
      fun(a);
      return ;
      }
      #include<iostream>
      #include<cmath>
      #include<stdio.h>
      using namespace std;
      int main()
      { int i, m = , n = , t;
      double s = 0.0;
      for (i = ; i <= ; i++)
      {
      s = s + (m * 1.0 / n);
      t = m+n;
      n = m; m = t;
      }
      printf("前20项之和为:%.2lf", s);
      return ;
      }

最新文章

  1. Error:identifer “blockIdx” and __syncthreads() undefined
  2. form表单验证和事件
  3. andriod 动态显示当前时间
  4. sqlserver2008链接服务器的使用和oracle11g客户端修改字符集
  5. 结合php ob函数理解缓冲机制
  6. UVALive4287 hdu2767 hdu3836 强连通
  7. Spring talk简单配置
  8. Linux开发工具之Makefile(上)
  9. 解决魅族手机连接win7连不上
  10. 数据加密算法---base64
  11. c - 逆序/正序输出每位.
  12. Problem I: STL——多重集的插入和删除
  13. 深入理解null的原理
  14. GBDT和XGBOOST算法原理
  15. win10下Resin安装--入门(1)
  16. Windows Server 2012 R2服务器部署Tomcat JDK、安装Mysql以及将Java项目部署到CVM
  17. React Fiber源码分析 第一篇
  18. trinitycore 魔兽服务器源码分析(一) 网络
  19. MVC基础篇—控制器与视图数据的传递
  20. Qt编写网络中转服务器(开源)

热门文章

  1. vue分组全选权限,CheckBoxGroup
  2. Macbook Pro 键盘触摸板失灵,只有电源键有反应 修复手札
  3. python 启动pydoc查看文档
  4. eclipse debug调试 class文件 Source not found.
  5. 冰多多团队-第八次Scrum例会
  6. [BUAA软工]提问回顾与个人总结
  7. Guava集合工具
  8. Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39; could not resolve com.android.support:design:28.0.0
  9. parquet 简介(转)
  10. Class-SP:Order.cs