当前位置:网站首页>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;
}
边栏推荐
- 机器学习之数据类型案例——基于朴素贝叶斯法,用数据辩男女
- C语言之最小数
- 数构(C语言--代码有注释)——第二章、线性表(更新版)
- Say goodbye to 996. What are the necessary plug-ins in idea?
- Dix ans d'expérience dans le développement de programmeurs vous disent quelles compétences de base vous manquez encore?
- [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)
- Matplotlib swordsman - a stylist who can draw without tools and code
- [go practical basis] gin efficient artifact, how to bind parameters to structures
- MySQL事务
- Pool de connexion redis personnalisé
猜你喜欢

JDBC回顾

Chrome browser plug-in fatkun installation and introduction

个人经历&&博客现状
![[go practical basis] how to bind and use URL parameters in gin](/img/63/84717b0da3a55d7fda9d57c8da2463.png)
[go practical basis] how to bind and use URL parameters in gin

十年開發經驗的程序員告訴你,你還缺少哪些核心競爭力?

Customize redis connection pool

Chrome user script manager tempermonkey monkey
![[go practical basis] how to verify request parameters in gin](/img/de/50db131d6993e5d955e3416c667c4c.png)
[go practical basis] how to verify request parameters in gin

Jd.com interviewer asked: what is the difference between using on or where in the left join association table and conditions

每天睡前30分钟阅读Day6_Day6_Date_Calendar_LocalDate_TimeStamp_LocalTime
随机推荐
每天睡前30分钟阅读Day6_Day6_Date_Calendar_LocalDate_TimeStamp_LocalTime
Talk about the secret of high performance of message queue -- zero copy technology
Dix ans d'expérience dans le développement de programmeurs vous disent quelles compétences de base vous manquez encore?
[go practical basis] how can gin get the request parameters of get and post
Chrome user script manager tempermonkey monkey
Matplotlib剑客行——初相识Matplotlib
"Interview high frequency question" is 1.5/5 difficult, and the classic "prefix and + dichotomy" application question
JVM instruction mnemonic
Chrome浏览器标签管理插件–OneTab
Typeerror: X () got multiple values for argument 'y‘
微服务实战|声明式服务调用OpenFeign实践
CKEditor 4.10.1 上传图片提示“不正确的服务器响应” 问题解决
Microservice practice | load balancing component and source code analysis
企业级SaaS CRM实现
Long summary (code with comments) number structure (C language) -- Chapter 4, string (Part 1)
FragmentTabHost实现房贷计算器界面
Matplotlib swordsman Tour - an artist tutorial to accommodate all rivers
Don't look for it. All the necessary plug-ins for Chrome browser are here
[staff] common symbols of staff (Hualian clef | treble clef | bass clef | rest | bar line)
Enterprise level SaaS CRM implementation