当前位置:网站首页>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;
}
边栏推荐
- Matplotlib swordsman line - layout guide and multi map implementation (Updated)
- 分享一篇博客(水一篇博客)
- Web security and defense
- Read Day5 30 minutes before going to bed every day_ All key values in the map, how to obtain all value values
- 互联网API接口幂等设计
- MySql报错:unblock with mysqladmin flush-hosts
- vs+qt 设置应用程序图标
- Int to string, int to qstring
- QT qlabel style settings
- FragmentTabHost实现房贷计算器界面
猜你喜欢
Learn combinelatest through a practical example
kinect dk 获取CV::Mat格式的彩色RGB图像(openpose中使用)
Chrome浏览器插件-Fatkun安装和介绍
Matplotlib swordsman line - layout guide and multi map implementation (Updated)
Chrome browser tag management plug-in – onetab
How to use pyqt5 to make a sensitive word detection tool
Creation and jump of activity
TD conducts functional simulation with Modelsim
Number structure (C language) -- Chapter 4, compressed storage of matrices (Part 2)
A detailed explanation takes you to reproduce the statistical learning method again -- Chapter 2, perceptron model
随机推荐
Int to string, int to qstring
道阻且长,行则将至
Say goodbye to 996. What are the necessary plug-ins in idea?
2837xd 代码生成——StateFlow(3)
Oracle modifies tablespace names and data files
Mathematics in machine learning -- point estimation (I): basic knowledge
Mysql 多列IN操作
自定義Redis連接池
每天睡前30分钟阅读Day5_Map中全部Key值,全部Value值获取方式
图像识别-数据增广
Microservice practice | load balancing component and source code analysis
What is the function of laravel facade
Read Day5 30 minutes before going to bed every day_ All key values in the map, how to obtain all value values
BugkuCTF-web16(备份是个好习惯)
In depth analysis of how the JVM executes Hello World
PI control of grid connected inverter (grid connected mode)
BugkuCTF-web21(详细解题思路及步骤)
大学生四六级作文模板(自创版,成功跨过六级)
MySql报错:unblock with mysqladmin flush-hosts
JVM instruction mnemonic