没有合适的资源?快使用搜索试试~ 我知道了~
江苏计算机C语言上机试题45道.pdf
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 25 浏览量
2022-07-14
18:08:46
上传
评论
收藏 232KB PDF 举报
温馨提示
![preview](https://dl-preview.csdnimg.cn/86177406/0001-4914eda93ffe5a36d788f0d8dda46f64_thumbnail.jpeg)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
试读
43页
江苏计算机C语言上机试题45道.pdf
资源推荐
资源详情
资源评论
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![](https://csdnimg.cn/release/download_crawler_static/86177406/bg1.jpg)
45 置换矩阵中的某个特定数。
#include<stdio.h>
#include<conio.h>
void matrix_change(int x[][3], int n)
{
int i, j, k, t[5] = {0}, max, maxi, maxj, v;
max = x[0][0];maxi = maxj = 0;
for (i = 0;i < n;i++)
for (j = 0;j < 3;j++)
if (x[i][j] > max){max = x[i][j];maxi = i;maxj = j;}
k = 0;
while (max > 0){t[k++] = max % 10;max = max / 10;}
for (i = 0;i < k;i++)
for (j = 0;j < k - i - 1;j++)
if (t[j] < t[j + 1]){v = t[j];t[j] = t[j + 1];t[j + 1] = v;}
for (i = 0;i < k;i++)
max = max * 10 + t[i];
x[maxi][maxj] = max;
}
void main()
{
int a[3][3] = {4, 8, 16, 32, 64, 128, 256, 512, 1024}, i, j;FILE * fp;
matrix_change(a, 3);
fp = fopen("myf2.out", "w");
if (fp == NULL)
{ printf("can't open file"); return ;}
for (i = 0;i < 3;i++)
{ for (j = 0;j < 3;j++)
{fprintf(fp, "%5d", a[i][j]); printf("%5d", a[i][j]);}
printf("");
fprintf(fp, "");
}
printf("My exam number is:WLJY001");
fprintf(fp, " My exam number is:WLJY001");
fclose(fp);
getch();
}
44 找出满足下列条件的整数对( m,n):(1)m 小于 n(2)a(m)=a(n)=m+n+1 ,其中 a(m)表示
m 的所有因子和, a(n)同上;
#include<stdio.h>
#include<conio.h>
int factor(int n)
![](https://csdnimg.cn/release/download_crawler_static/86177406/bg2.jpg)
{ int i, s = 0;
for (i = 1;i <= n;i++)
if (n % i == 0)s = s + i;
return s;
}
int fun(int n, int a[][2])
{ int i, j, g1, g2, k = 0;
for (i = 2;i <= n;i++)
{
g1 = factor(i);
for (j = 1;j < i;j++)
{
g2 = factor(j);
if (g1 == g2 && g1 == i + j + 1)
{a[k][0] = j;a[k++][1] = i;}
}
}
return k;
}
void main()
{
FILE *fp;int i, n, m, a[100][2];
if ((fp = fopen("myf2.out", "w")) == NULL)
{printf("The file call not open!");exit(0);}
scanf("%d", &n);
m = fun(n, a);
for (i = 0;i < m;i++)
{
printf("(%d,%d)\n", a[i][0], a[i][1]);
fprintf(fp, "(%d,%d)\n", a[i][0], a[i][1]);
}
printf("\nMy exam number is:WLJY001\n");
fprintf(fp, "\nMy exam number is:WLJY001\n");
fclose(fp);
getch();
}
43 将一个十进制整数 m 转换成 r 进制整数的字符串表示形式。
#include<stdio.h>
#include<stdlib.h>
void trdec(char *str, int idec, int ibase)
{char ch;
int i, idr, k = 0;
![](https://csdnimg.cn/release/download_crawler_static/86177406/bg3.jpg)
while (idec != 0)
{
idr = idec % ibase;
if (idr >= 10)
str[k++] = idr - 10 + 'A';
else
str[k++] = idr + '0';
idec /= ibase;
}
for (i = 0;i < k / 2;i++)
{ch = str[i];
str[i] = str[k - i - 1];
str[k - i - 1] = ch;
}
str[k] = '\0';
}
void main()
{
int x;char str[20];FILE *fp;
if ((fp = fopen("myf2.out", "w")) == NULL)
{printf("The file can not open!");exit(0);}
printf("Enter a number"); scanf("%d", &x);
trdec(str, x, 2);
printf("%sB,", str);fprintf(fp, "%sB,", str);
trdec(str, x, 8);
printf("%sQ,", str);fprintf(fp, "%sQ,", str);
trdec(str, x, 16);
printf("%sH\n", str);fprintf(fp, "%sH\n", str);
printf("\nMy exam number is:WLJY001\n");
fprintf(fp, "\nMy exam number is:WLJY001\n");
fclose(fp);
}
42 已知 x 数组中存储的 n 接矩阵有一个鞍点(鞍点是指该位置上的数十所在行的最大数,
同时也是所在列的最小数) ,程序实现将矩阵中鞍点所在列移动到最右侧。
#include<stdio.h>
#include<conio.h>
#define N 4
void move(int a[][N])
{
int i, j, k, f, t, m, mj;
for (i = 0;i < N;i++)
{
m = a[i][0];mj = 0;f = 1;
for (j = 0;j < N;j++)
![](https://csdnimg.cn/release/download_crawler_static/86177406/bg4.jpg)
if (a[i][j] > m)
{
m = a[i][j];mj = j;
}
for (k = 0;k < N && f;k++)
if (a[k][mj] < m)
f = 0;
if (k >= N)break;
}
if (f)
{
printf("An dian :a[%d][%d]\n", i, mj);
for (i = 0;i < N;i++)
{
t = a[i][mj];
for (j = mj;j < N - 1;j++)
a[i][j] = a[i][j + 1];
a[i][N - 1] = t;
}
}
}
void main()
{
int x[N][N] = {{1, 3, 2, 0}, {4, 6, 5, -1}, {7, 9, 8, 0}, { -1, 10, 3, 2}}, i, j;
for (i = 0;i < N;i++)
{
for (j = 0;j < N;j++)
printf("%3d", x[i][j]);
printf("\n");
}
printf("\n");
move(x);
for (i = 0;i < N;i++)
{
for (j = 0;j < N;j++)
printf("%3d", x[i][j]);
printf("\n");
getch();
}
}
41 在给定的范围内查找满足特定条件的整数。
#include<stdio.h>
#include<conio.h>
![](https://csdnimg.cn/release/download_crawler_static/86177406/bg5.jpg)
#include<math.h>
int find(long n1, long n2, long x[])
{ long i, y;
int j, m = 0, k = 0, f, t[10], d[10];
for (i = n1;i <= n2;i++)
{for (j = 0;j < 10;j++) d[j] = 0;
y = i * i;
f = 1;m = 0;
for (j = 2;j < i;j++)
if (i % j == 0){f = 0;break;}
if (!f)continue;
while (y > 0){t[m++] = y % 10;y = y / 10;}
for (j = 0;j < m;j++)
{
d[t[j]]++;
if (d[t[j]] > 1){f = 0;break;}
}
if (f)
x[k++] = i;
}
return k;
}
main()
{
long a[50], i, n;
FILE *fp = fopen("myf2.out", "w");
if (fp == NULL){printf("can't open file"); return ;}
n = find(1000, 1500, a);
for (i = 0;i < n;i++)
{ printf("\n%ld%ld", a[i], a[i]*a[i]);
fprintf(fp, "\n%ld %ld", a[i], a[i]*a[i]);}
printf("\nMy exam number is:WLJY001\n");
fprintf(fp, " \nMy exam number is:WLJY001\n");
fclose(fp);
getch();
}
40 求级数的前 n 项之和。编写函数 double fun(double x,int n)
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define N 40
double fun(double x, int n)
剩余42页未读,继续阅读
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
hyj15659071652
- 粉丝: 0
- 资源: 7万+
![benefits](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-1.c8e153b4.png)
下载权益
![privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-2.ec46750a.png)
C知道特权
![article](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-3.fc5e5fb6.png)
VIP文章
![course-privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-4.320a6894.png)
课程特权
![rights](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-icon.fe0226a8.png)
开通VIP
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)