当前位置:网站首页>c语言编程题
c语言编程题
2022-07-02 06:34:00 【懵懂的梦花火】

#include "stdafx.h"
#include <stdio.h>
#include <malloc.h>
int main(int argc, char* argv[])
{
int i, number, *p;
scanf("%d", &number); // 输入向量长度
p = (int*)malloc(sizeof(int)*number*2); // 申请长度为number个int的连续存储空间
printf("请输入长度为%d的两个向量:\n",number);
for (i = 0; i < number*2; i++)
{
scanf("%d", &p[i]); // 获取输入流中的数据(以int进行解析)
}
int result = 0;
// 计算向量内积
for (i = 0; i < number; i++)
{
result+= (p[i] * p[i+number]);
}
printf("result is %d\n", result);
return 0;
}

#include "stdafx.h"
#include <stdio.h>
#include <malloc.h>
struct RowMin
{
int value;
int row;
int col;
};
int main(int argc, char* argv[])
{
int i, number, *p;
scanf("%d", &number);
p = (int*)malloc(sizeof(int)*number*number); // 申请内存空间n*n长度
printf("请输入长度为%d*%d的数组:\n",number,number);
for (i = 0; i < number*number; i++)
{
scanf("%d", &p[i]);
}
// 找出每一行的最小值
RowMin *pRowMin = (RowMin*)malloc(sizeof(RowMin)*number); // 存储每一行的最小值
for (i = 0; i < number; i++)
{
pRowMin[i].value = p[number*i];
pRowMin[i].row = i;
pRowMin[i].col = 0;
for (int j = 1; j < number; j++)
{
if (p[number*i+j] < pRowMin[i].value)
{
pRowMin[i].value = p[number*i+j];
pRowMin[i].col = j;
}
}
}
// 找出每一行的最大值
int max = 0;
for (i = 1; i < number; i++)
{
if (pRowMin[max].value < pRowMin[i].value)
{
max = i;
}
}
printf("result is %d,%d,%d\n", pRowMin[max].value, pRowMin[max].row, pRowMin[max].col);
return 0;
}
边栏推荐
- 破茧|一文说透什么是真正的云原生
- Ora-12514 problem solving method
- Pdf document of distributed service architecture: principle + Design + practice, (collect and see again)
- Customize redis connection pool
- How to choose between efficiency and correctness of these three implementation methods of distributed locks?
- 上班第一天的报错(AWVS卸载不彻底)
- Demand delineation executive summary
- 每天睡前30分钟阅读Day6_Day6_Date_Calendar_LocalDate_TimeStamp_LocalTime
- Amq6126 problem solving ideas
- idea查看字节码配置
猜你喜欢

Flink - use the streaming batch API to count the number of words

MySQL事务

"Redis source code series" learning and thinking about source code reading

Redis 序列化 GenericJackson2JsonRedisSerializer和Jackson2JsonRedisSerializer的区别

A detailed explanation takes you to reproduce the statistical learning method again -- Chapter 2, perceptron model
![[staff] common symbols of staff (Hualian clef | treble clef | bass clef | rest | bar line)](/img/ae/1ecb352c51a101f237f244da5a2ef7.jpg)
[staff] common symbols of staff (Hualian clef | treble clef | bass clef | rest | bar line)
![[staff] time mark and note duration (staff time mark | full note rest | half note rest | quarter note rest | eighth note rest | sixteenth note rest | thirty second note rest)](/img/7f/2cd789339237b7a881bfed7b7545a9.jpg)
[staff] time mark and note duration (staff time mark | full note rest | half note rest | quarter note rest | eighth note rest | sixteenth note rest | thirty second note rest)

Insight into cloud native | microservices and microservice architecture
![[staff] the lines and spaces of the staff (the nth line and the nth space in the staff | the plus N line and the plus N space on the staff | the plus N line and the plus N space below the staff | the](/img/dc/c0ea188ef353ded86759dbe9b29df3.jpg)
[staff] the lines and spaces of the staff (the nth line and the nth space in the staff | the plus N line and the plus N space on the staff | the plus N line and the plus N space below the staff | the

概率还不会的快看过来《统计学习方法》——第四章、朴素贝叶斯法
随机推荐
微服务实战|负载均衡组件及源码分析
Watermelon book -- Chapter 5 neural network
How to install PHP in CentOS
Discussion on improving development quality and reducing test bug rate
Typora安装包分享
Matplotlib剑客行——初相识Matplotlib
A detailed explanation takes you to reproduce the statistical learning method again -- Chapter 2, perceptron model
Cloudrev self built cloud disk practice, I said that no one can limit my capacity and speed
Mysql默认事务隔离级别及行锁
C语言之做木桶
机器学习之数据类型案例——基于朴素贝叶斯法,用数据辩男女
企业级SaaS CRM实现
web安全与防御
Oracle modify database character set
Complete solution of servlet: inheritance relationship, life cycle, container, request forwarding and redirection, etc
VIM操作命令大全
[go practical basis] how to install and use gin
What are the differences between TP5 and laravel
[go practical basis] how to set the route in gin
Knowledge points are very detailed (code is annotated) number structure (C language) -- Chapter 3, stack and queue