当前位置:网站首页>8.8.4-PointersOnC-20220215
8.8.4-PointersOnC-20220215
2022-07-02 00:56:00 【fleet1126】
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int Is_Identity_Matrix(int **arr,int num);
int main(){
int row=0,ch=0,**matrix=NULL;
srand((unsigned int)time(0));
for(fputs("Input the row of matrix:->",stdout);(ch=scanf_s("%d",&row))!=1||row>30;fputs("Input the row of matrix:->",stdout))
while((ch=getchar())!=EOF&&ch!=10);
matrix=(int **)calloc(row,sizeof(int *));
for(int i=0;i<row;matrix[i]=(int *)calloc(row,sizeof(int)),i++);
for(int i=0;i<row;matrix[i][i]=1,i++);// Build a cell matrix
matrix[rand()%row][rand()%row]=1;// Change a random position to 1
for(int i=0;i<row;i++){
for(int j=0;j<row;j++)
printf("%d ",matrix[i][j]);
fputc(10,stdout);
}
printf("The matrix with %d rows %s IdentityMatrix.\n",row,Is_Identity_Matrix(matrix,row)?"is":"isn't");
for(int i=0;i<row;free(matrix[i]),matrix[i]=NULL,i++);
free(matrix);
matrix=NULL;
}
//
int Is_Identity_Matrix(int **arr,int num){
for(int i=0;i<num;i++)
for(int j=0;j<num;j++)
if(arr[i][j]!=(i==j))
return 0;
return 1;}
/*
1 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 1
*/边栏推荐
- Leetcode skimming: stack and queue 03 (valid parentheses)
- Review notes of compilation principles
- Global and Chinese market of collaborative applications 2022-2028: Research Report on technology, participants, trends, market size and share
- Node - generate wechat permission verification configuration
- 【CTF】bjdctf_2020_babystack2
- Node——生成微信权限验证配置
- [conference resources] the Third International Conference on Automation Science and Engineering in 2022 (jcase 2022)
- Leetcode skimming: stack and queue 06 (top k high-frequency elements)
- [JS download files through url]
- Excel search and reference function
猜你喜欢

SSO single sign on implementation.

What does open loop and closed loop mean?
![[eight sorts ②] select sort (select sort, heap sort)](/img/4b/da0d08230391d6ee48cd8cfd2f7240.png)
[eight sorts ②] select sort (select sort, heap sort)

创业团队如何落地敏捷测试,提升质量效能?丨声网开发者创业讲堂 Vol.03

JS -- image to base code, base to file object

AIX存储管理之逻辑卷的创建及属性的查看和修改

XMind思维导图
![[conference resources] the Third International Conference on Automation Science and Engineering in 2022 (jcase 2022)](/img/a6/a2afdf9e18255c9171f61bf074998b.png)
[conference resources] the Third International Conference on Automation Science and Engineering in 2022 (jcase 2022)

JMeter做接口测试,如何提取登录Cookie

How can entrepreneurial teams implement agile testing to improve quality and efficiency? Voice network developer entrepreneurship lecture Vol.03
随机推荐
【八大排序③】快速排序(动图演绎Hoare法、挖坑法、前后指针法)
Node——生成微信权限验证配置
Global and Chinese markets of beverage seasoning systems 2022-2028: Research Report on technology, participants, trends, market size and share
Zak's latest "neural information transmission", with slides and videos
Some understandings of graph convolution neural network r-gcn considering relations and some explanations of DGL official code
Global and Chinese markets of digital crosspoint switches and mux/demux 2022-2028: Research Report on technology, participants, trends, market size and share
【CTF】bjdctf_2020_babystack2
If the browser is accidentally closed, how does react cache the forms filled out by users?
sso单点登录的实现。
Friends circle community program source code sharing
export default 导出的对象,不能解构问题,和module.exports的区别
LeetCode 0241. Design priority for arithmetic expressions - DFS
Creation of volume group for AIX storage management (I)
RFID让固定资产盘点更快更准
【js通过url下载文件】
[eight sorting ③] quick sorting (dynamic graph deduction Hoare method, digging method, front and back pointer method)
Global and Chinese markets for context and location-based services 2022-2028: Research Report on technology, participants, trends, market size and share
测试人进阶技能:单元测试报告应用指南
How to open an account for individual stock speculation? Is it safe?
创业团队如何落地敏捷测试,提升质量效能?丨声网开发者创业讲堂 Vol.03