日韩色综合-日韩色中色-日韩色在线-日韩色哟哟-国产ts在线视频-国产suv精品一区二区69

手機APP下載

您現在的位置: 首頁 > 考研英語 > 考研專業課 > 吉林大學 > 正文

吉林大學2003年c語言程序設計專業課考研真題試卷及答案(回憶版)

來源:可可英語 編輯:max ?  可可英語APP下載 |  可可官方微信:ikekenet

2003-1/*====================================================================================*/
/*函數名稱:2003_1.c                                  */
/*程序目的:將由整數構成的n(n≥2)階方陣A就地按順時針方向旋轉90度           */
/*Writen by Apechn ,Soft Lab of JLU                          */
/*====================================================================================*/
#include
const int N = 9;
void main()
{
 int a[N][N];
 int i,j,temp = 1,x = 0,y = N;
 for (i = 0;i<N;i++) //賦初值
  for (j = 0;j  {
   a[i][j] = temp;
   temp++;
  }
 for (i = 0;i<N-1;i++) //核心部分
 {
  for (j = x;j<y-1;j++) //根據題目要求,設計出如下幾條地址變換規律
  {
   temp = a[i][j];
   a[i][j] = a[N-j-1][i];
   a[N-j-1][i] = a[N-i-1][N-j-1];
   a[N-i-1][N-j-1] = a[j][N-i-1];
   a[j][N-i-1] = temp;
  }

  x++;
  y--;
 }
 for (i = 0;i for (j = 0;j printf("%d ",a[i][j]);
}
2003-2/*====================================================================================*/
/*函數名稱:2003_2.c                                  */
/*程序目的:將一個實數分解為它的整數和小數部分                     */
/*Writen by Apechn ,Soft Lab of JLU                          */
/*====================================================================================*/
#include
#define GET_ZHENGSHU 0; //宏定義,便于使用
#define GET_XIAOSHU 1
float fun(float f,int sign);
void main()
{
  float a;
  printf("Please input a:");
  scanf("%f",&a);
  printf("整數部分為:%f/n",fun(a,GET_ZHENGSHU));//取整數的使用方法
  printf("小數部分為:%f/n",fun(a,GET_XIAOSHU)); //取小數的使用方法
}
float fun(float f,int sign)
{
  float a = 0;
  if (f>=0)
  {
   while (a<=f) //枚舉
      a = a + 1;
   a = a - 1;
  }
  else
  {
   while (a>=f) //枚舉
      a = a - 1;
   a = a + 1;
  }
  if (sign == 0)
   return a;
  else
   return (f - a);
}
2003-3/*====================================================================================*/
/*函數名稱:2003_3.c                                  */
/*程序目的:對于0<x<1,利用Talor公式,求e^x的近似值,結果精確到10^-8           */
/*Writen by Apechn ,Soft Lab of JLU                          */
/*====================================================================================*/
#include
#include
double e(int x);
void main()
{
  int x;
  printf("Please input x: ");
  scanf("%d",&x);
  printf("/n The result is :%15.8f",e(x));
}
double e(int x)
{
  double result1,result2;
  double c = 1; //除數
  double b = x; //被除數
  int m = 1;
  result1 = 1 + x;
  result2 = 1;
  while (fabs(result1 - result2) >= 1E-8) //控制精確度
  {
   m++;
   c = c * m;
   b = b * x;
   result2 = result1;
   result1 = result1 + b/c;
  }
  return result1;
}
2003-4/*====================================================================================*/
/*函數名稱:2003_4.c                                  */
/*程序目的:從輸入的字符串中翻譯并輸出符合該句法的一個數                */
/*Writen by Apechn ,Soft Lab of JLU                          */
/*====================================================================================*/
#include
#include
int isdigtal(char c);
int todig(char c);
void compile(char* str);
void main()
{
  char str[40];
  printf("Please input a string: ");
  scanf("%s",str);
  compile(str);
}
void compile(char* str)
{
  double num = 0;
  int sign = 0,exp = 0;
  char *p = str,c;
  c = *p;
  while (c != '/0')
  {
    if (isdigtal(c)) //如果c是數字
    {
      switch(sign)
      {
        case 0:
          sign = 1;
          num = todig(c);
          break;
        case 1:
          num = num * 10 + todig(c);
          break;
        case 2:
          num = num + todig(c) * pow(10,exp);
          exp--;
          break;
       }
    }
    else if (c == '.') //如果c是小數點
    {
      if (sign == 1)
      {
        sign = 2;
        exp = -1;
      }
    }
    else //如果c是其它字符
    {
      if (sign != 0)
      {
        printf("the number is :%f/n",num);
        return;
      }
    }
    p = p + 1;
    c = *p;
  }

  printf("the number is :%f/n",num);
}
2003-5/*====================================================================================*/
/*函數名稱:2003_5.c                                  */
/*程序目的:將遞歸函數轉化為非遞歸函數                         */
/*Writen by Apechn ,Soft Lab of JLU                          */
/*====================================================================================*/
float f1(float x,float y)
{
  if (x<0)
    return x+y;
  return f1(x-1,x+y) + x/y;
}
float f2(float x,float y)
{
  float result,a,b;
  if (x<0)
    return x+y;
  result = x/y;
  a = x;
  b = y;
  while (a>=0)
  {
    b = a + b;
    a = a - 1;
    result = result + a/b;
  }
  result = result + (a + b);
  return result;
}
2003-6/*=============================================================================*/
/*程序名稱:2003_6.c                              */
/*程序目的:從已知二叉樹的前序和中序序列構造該二叉樹              */
/*Writen by Apechn ,Soft Lab of JLU                       */
/*=============================================================================*/

#include
struct node //定義鏈表結點結構,在最前面給出
{
 int data;
 node *left;
 node *right;
}
node *bintree(int i,j,u,v;node *s)
{
 int k,l;
 s = NULL; //根指針初始化,s為空樹
 if (j >= i)
 {
  s = node *(malloc(sizeof(node)));//建立根結點
  s->data = pre[i];
  k = u;
  while (ind[k] != pre[i]) //在中序序列中查找根結點
   k++;
  l = i + k - u; //l為左字樹中最右下結點在前序序列中的位置
  if (k == u) //構造左子樹
   s->left = NULL;
  else
   bintree(i+1,l,u,k-1,s->left);
  if (k == v) //構造右子樹
   s->right = NULL;
  else
   bintree(l+1,j,k+1,v,s->right);
 }
}
2003-7/*====================================================================================*/
/*函數名稱:2003_7.c                                  */
/*程序目的:求由100個整數構成的序列L的最大和子序列                   */
/*Writen by Apechn ,Soft Lab of JLU                          */
/*====================================================================================*/
#include
#include
#include
const int N = 100;
void main()
{
  int A[N],stime;
  long ltime;
  int a = 0,b = 0,i,j,k,num = 0,max = -100;
  ltime = time(NULL);
  stime = (unsigned)ltime/2;
  srand(stime);
  for (i = 0;i    A[i] = rand() % 100 - 50;

  printf("/nThe subserial is :/n");
  for (i = 0;i<N;i++)         //主要部分
    for (j = N-1;j>=i;j--)
    {                //i和j為子序列的邊界
      num = 0;
      for (k = i;k<=j;k++)
        num += A[k];      //求出子序列的和
      if (num > max)        //如果當前序列的和大于記錄,那么記下邊界
      {
        max = num;
        a = i;
        b = j;
      }
    }
  for (k = a;k<=b;k++)
    printf("%3d",A[k]);
}
2003-8/*====================================================================================*/
/*函數名稱:2003_8.c                                  */
/*程序目的:編程根據經過合理變換得到的序列B中的數據,依次輸出序列A中的數值       */
/*Writen by Apechn ,Soft Lab of JLU                          */
/*====================================================================================*/
#include
const int N = 10;
void main()
{
  int A[N],b[N] = {0,1,0,3,2,3,2,4,0,4};
  int temp[N] = {1,2,3,4,5,6,7,8,9,10};   //臨時數組,在確定A時使用
  int i,j,k;
  for (i = N - 1;i>=0;i--)          //對數組B從后向前掃描
  {
    k = B[i];
    j = 0;
    while (k != 0)             //從臨時數組temp中找到k=B[i]個沒有確定下來的數
    {
      if (temp [j] != N + 1)
        k--;
      j++;
    }
    while (temp[j] == N + 1)       //找到下一個還沒有被確定下來的數
      j++;               //就應該放到A[i]處
    A[i] = temp[j];
    temp[j] = N + 1;
  }
  for (i = 0;i    printf("%d ",A[i]);
}

?
發布評論我來說2句

    最新文章

    可可英語官方微信(微信號:ikekenet)

    每天向大家推送短小精悍的英語學習資料.

    添加方式1.掃描上方可可官方微信二維碼。
    添加方式2.搜索微信號ikekenet添加即可。
    主站蜘蛛池模板: 少年团时代成员| 美女又黄又免费的视频| 雾化吸入ppt课件| 杀破狼·贪狼 2017 古天乐| 骨妹| 翟佳滨老师今天答案| 名星| 尤勇个人资料简介简历| 欧美变态挠痒痒视频∨k| 芝加哥警署第九季| 电影《追求》| 赖小子在线观看完整视频高清| 日本xxx.| 哪吒电影1| 女同性恨| 真实游戏电影无删减完整版| 来自地狱| cctv5+体育赛事直播时间| 高一英语单词表电子版| overwatch| 小宏人司机版| 天涯海角论坛官网登录入口| 老牛家的战争电视剧全集免费观看| 谁的青春不迷茫 电影| 漫画头像女生可爱| 美容室4| 刘一秒攻心销售| 娄际成| 我的一级兄弟| 向团组织靠拢的打算| 李安娜| 太太的情人电影| 南来北往电视剧40集免费观看| 嗯啊主人| 夜夜女人香| 浙江卫视节目在线观看直播| 电影《uhaw》免费观看| 美式壁纸| 范瑞君| 媚狐传| 南果步|