当前位置:网站首页>C language programming problems
C language programming problems
2022-07-02 09:39:00 【Ignorant dream fireworks】

#include "stdafx.h"
#include <stdio.h>
#include <malloc.h>
int main(int argc, char* argv[])
{
int i, number, *p;
scanf("%d", &number); // Enter the vector length
p = (int*)malloc(sizeof(int)*number*2); // Application length is number individual int Of continuous storage space
printf(" Please enter a length of %d Two vectors of :\n",number);
for (i = 0; i < number*2; i++)
{
scanf("%d", &p[i]); // Gets the data in the input stream ( With int To analyze )
}
int result = 0;
// Compute the inner product of a vector
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); // Apply for memory space n*n length
printf(" Please enter a length of %d*%d Array of :\n",number,number);
for (i = 0; i < number*number; i++)
{
scanf("%d", &p[i]);
}
// Find the minimum value of each line
RowMin *pRowMin = (RowMin*)malloc(sizeof(RowMin)*number); // Store the minimum value of each row
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;
}
}
}
// Find the maximum value of each row
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;
}
边栏推荐
- Knife4j 2. Solution to the problem of file control without selection when uploading x version files
- Int to string, int to qstring
- Double non undergraduate students enter the factory, while I am still quietly climbing trees at the bottom (Part 1)
- FragmentTabHost实现房贷计算器界面
- Microservice practice | declarative service invocation openfeign practice
- Pool de connexion redis personnalisé
- DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!
- Matplotlib swordsman - a stylist who can draw without tools and code
- Web security and defense
- 告别996,IDEA中必装插件有哪些?
猜你喜欢

tinyxml2 读取和修改文件

Web security and defense

保存视频 opencv::VideoWriter

图像识别-数据清洗

Typora installation package sharing

2837xd 代码生成——StateFlow(3)

三相逆变器离网控制——PR控制

Say goodbye to 996. What are the necessary plug-ins in idea?

Read 30 minutes before going to bed every day_ day4_ Files

Operation and application of stack and queue
随机推荐
上班第一天的报错(Nessus安装winpcap报错)
Mysql默认事务隔离级别及行锁
Inverter Simulink model -- processor in the loop test (PIL)
攻防世界-Web进阶区-unserialize3
QT signal slot summary -connect function incorrect usage
图像识别-数据清洗
int与string、int与QString互转
Chrome浏览器标签管理插件–OneTab
Typeerror: X () got multiple values for argument 'y‘
自定義Redis連接池
告别996,IDEA中必装插件有哪些?
企业级SaaS CRM实现
web安全与防御
Pool de connexion redis personnalisé
C语言之做木桶
Enterprise level SaaS CRM implementation
Insight into cloud native | microservices and microservice architecture
Int to string, int to qstring
What are the differences between TP5 and laravel
Navicat remote connection MySQL reports an error 1045 - access denied for user 'root' @ '222.173.220.236' (using password: yes)