C
ML__LM
越努力,越幸运
展开
-
C语言如何打印 4×1024的整数矩阵,且数据是对齐的
如何保证每一列的数据是对齐的? for(i=0; i<COUNT; i++) { printf(" %-9.0f %-9.0f %-9.0f %-9.0f %-9.0f %-9.0f %-9.0f %-9.0f\r\n", beam_1[i].real,beam_1[i].img, beam_2[i].real, beam_2[i].img, beam_3[i].real, beam_3[i].img, beam_4[i].real, beam_4[原创 2021-10-02 16:53:48 · 651 阅读 · 0 评论 -
C语言计算程序执行时间
#include <stdio.h>#include <stdlib.h>#include <time.h>int i;int main(){ clock_t begin, end; double cost; //开始记录 begin = clock(); /*待测试程序段*/ for (i=0;i<1000;i++) { printf("hello world!\n"); } //结束记原创 2021-07-31 10:17:54 · 1281 阅读 · 0 评论 -
C语言如何实现返回子函数的多个参数
如何某个子函数待返回的两个参数1 源代码2 结果1 源代码// 如何某个子函数待返回的两个参数#include<stdio.h> // 某个子函数待返回的两个参数int theta0=45;int fine0=180;main(){ int angle=0; angle=theta0*1000+fine0; printf("theta0 is %d \n\r" , angle/1000); printf("fine0 is %d \n\r" , a原创 2021-07-23 09:53:00 · 1445 阅读 · 0 评论 -
找数组的最大值所对应的下标
1 源代码//函数功能:找数组的最大值所对应的下标#include<stdio.h> double u_amp[10]={1,2,3,4,5,10,9,8,7,6};main(){ int pp; double max=0.0; int angle; for(pp=0;pp<10;pp++) { if(u_amp[pp]>max) { max = u_amp[pp]; angle=pp; } } printf("max is原创 2021-07-21 16:20:11 · 463 阅读 · 0 评论 -
C语言之复数的加减乘除
C语言之复数的加减乘除1 源代码2 结果1 源代码#include<stdio.h>#include<stdlib.h>// 定义一个结构体typedef struct//结构体 { double real; double img; }complex; complex a={1,2}; //第一个数的实部和虚部 1+2i complex b={3,4}; complex c; //计算结果/******************原创 2021-07-09 16:07:18 · 4674 阅读 · 0 评论 -
C语言之多维数组
#include <stdio.h>int array[5][5] = {{10, 2,3,4,5}, {3, 4, 5}, {6}, {7}, {0, 8}}; /***************************** 子函数*****************************/void print_a(int array[][5], int n, int m) ;/*****************************原创 2021-07-03 16:21:50 · 123 阅读 · 0 评论 -
数组和指针的关系
数组和指针的关系1 基本原理2 源代码3 结果1 基本原理指针本质上是对地址进行操作,数组本质是也是对地址进行操作。所以,从这个角度上看,两者是一样的。2 源代码/* 注意点: 前后数据类型必须一致,要不然在打印过程中,结果为0 *(days+i)和days[i]表达的意思是一样的 days + i是元素days[i]的地址, *(days + i)则是days[i]该地址的值*//*----------一维数组-----------*/#include <st原创 2021-07-03 16:15:27 · 140 阅读 · 0 评论 -
C语言之二维数组
/*----------二维数组-----------*/#include <stdlib.h>#include <stdio.h>#define M 2#define N 3int rain[M][N];//内含2个数组元素的数组,每个数组元素内含3个int类型的元素int array[M][N]={{1,2,3},{5,6,7}};int main(int i,int j){ for (i=0;i<M;i++) { for (j=0;j<原创 2021-07-03 16:07:31 · 78 阅读 · 0 评论 -
C语言之指针(1)
指针p的三个关键量:p:和普通的变量a是一样的,不过a存放的是变量,p1存放的是地址&p:存放的是指针自己本身的内存地址*p:存放的是地址的值/********************************指针p p:和普通的变量a是一样的,不过a存放的是变量,p1存放的是地址&p:存放的是指针自己本身的内存地址*p:存放的是地址的值**********************************/#include<stdio.h>/****原创 2021-07-03 15:39:00 · 82 阅读 · 0 评论 -
C语言实现序列幅度估计的两种方法
C语言实现序列幅度估计的两种方法1 MATAB实现2 C语言实现2.1 mian函数2.2 amp_est.c2.3 amp_est.h1 MATAB实现%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 接收信号幅度估计%%%%%%%%%%%%%%%%%%%%%%%%%%%% close all;clear all;clc;%--------------参数定义count=4; % 采样点数y1=[1+2i,3+4i,5+6i,7+8i];y2=[10+20i原创 2021-06-22 10:11:59 · 259 阅读 · 0 评论 -
C语言不同进制转换
C语言不同进制转换1 十六进制转十进制1 十六进制转十进制#include "stdio.h"int main(){ int value_high=0x7a8; int g,s,b; int sum; g=(value_high/256 ); s=(value_high%256/16); b= value_high%16; sum=g*256+s*16+b*1; printf(" %d, %d, %d, %d\n", g, s, b, sum);}原创 2021-06-21 22:28:20 · 164 阅读 · 2 评论 -
C语言之结构体(1)
#include <stdio.h>struct{ char *name; //姓名 int num; //学号 int age; //年龄 char group; //所在小组 float score; //成绩 } stu1;int main(){ //给结构体成员赋值 stu1.name = "Tom"; stu1.num = 12; stu1.age = 18; stu1.group = 'A'; stu1.s原创 2021-05-10 20:32:51 · 94 阅读 · 0 评论 -
C语言实现估计信号的幅度
C语言实现估计信号的幅度思路:matlab实现仿真结果C语言实现仿真结果思路:1、对复序列做FFT变换2、得到序列的幅度谱3、找出幅度谱的最大值即为序列的幅度matlab实现close all;clear all;clc;count=4;y=[1+2i,3+4i,5+6i,7+8i];y_FFT=fft(y,count) % 傅里叶变换P=abs(y_FFT)/count % 幅度谱u=max(P) % 得到波束1接收到的信号的幅度值仿真结果C原创 2021-03-04 20:11:40 · 689 阅读 · 1 评论 -
C语言实现FFT or IFFT
C语言实现FFT or IFFTmatlab实现仿真结果C语言实现仿真结果matlab实现close all;clear all;clc;count=2;y=[1+2i,2+3i];y_FFT=fft(y,count); % 傅里叶变换P=abs(y_FFT)/count; % 幅度谱u=max(P); % 得到波束1接收到的信号的幅度值仿真结果C语言实现/************FFT***********/#include <stdi原创 2021-03-04 19:00:32 · 1374 阅读 · 2 评论 -
C语言实现函数调用的三种方法
第一种方法在一个.c文件里面进行子函数调用step1:函数声明step:mian函数step:子函数/******************************** 数组元素之和 法一: 子函数调用**********************************/#include<stdio.h>#define M 10 // 数组元素个数int num[M]={1,2,3,4,5,6,7,8,9,10};/**********原创 2021-01-28 21:53:20 · 32560 阅读 · 1 评论 -
调用外部C文件的方法
方法路径+外部函数名源代码main函数:/******************************** 数组元素之和 不需要.h文件,直接调用外部函数的方法**********************************/#include<stdio.h>#include "D:\mwq\LAB\z7\ARM\VC\extern_get_c_file\sum.c"//调用外部函数 路径+外部函数名#define M 10int an原创 2021-01-28 21:47:08 · 834 阅读 · 0 评论