#include <stdio.h> #include <stdlib.h> #define SMAX 100 typedef struct SPNode { int i,j,v; }SPNode; struct sparmatrix { int rows,cols,terms; SPNode data [SMAX]; }; sparmatrix CreateSparmatrix() { sparmatrix A; printf("\n\t\t請輸入稀疏矩陣的行數(shù),列數(shù)和非零元素個數(shù)(用逗號隔開):"); scanf("%d,%d,%d",&A.cols,&A.terms); for(int n=0;n<=A.terms-1;n++) { printf("\n\t\t輸入非零元素值(格式:行號,列號,值):"); scanf("%d,%d,%d",&A.data[n].i,&A.data[n].j,&A.data[n].v); } return A; } void ShowSparmatrix(sparmatrix A) { int k; printf("\n\t\t"); for(int x=0;x<=A.rows-1;x++) { for(int y=0;y<=A.cols-1;y++) { k=0; for(int n=0;n<=A.terms-1;n++) { if((A.data[n].i-1==x)&&(A.data[n].j-1==y)) { printf("%8d",A.data[n].v); k=1; } } if(k==0) printf("%8d",k); } printf("\n\t\t"); } } void sumsparmatrix(sparmatrix A) { SPNode *p; p=(SPNode*)malloc(sizeof(SPNode)); p->v=0; int k; k=0; printf("\n\t\t"); for(int x=0;x<=A.rows-1;x++) { for(int y=0;y<=A.cols-1;y++) { for(int n=0;n<=A.terms;n++) { if((A.data[n].i==x)&&(A.data[n].j==y)&&(x==y)) { p->v=p->v+A.data[n].v; k=1; } } } printf("\n\t\t"); } if(k==1) printf("\n\t\t對角線元素的和::%d\n",p->v); else printf("\n\t\t對角線元素的和為::0"); } int main() { int ch=1,choice; struct sparmatrix A; A.terms=0; while(ch) { printf("\n"); printf("\n\t\t 稀疏矩陣的三元組系統(tǒng) "); printf("\n\t\t*********************************"); printf("\n\t\t 1------------創(chuàng)建 "); printf("\n\t\t 2------------顯示 "); printf("\n\t\t 3------------求對角線元素和"); printf("\n\t\t 4------------返回 "); printf("\n\t\t*********************************"); printf("\n\t\t請選擇菜單號(0-3):"); scanf("%d",&choice); switch(choice) { case 1: A=CreateSparmatrix(); break; case 2: ShowSparmatrix(A); break; case 3: SumSparmatrix(A); break; default: system("cls"); printf("\n\t\t輸入錯誤!請重新輸入!\n"); break; } if (choice==1||choice==2||choice==3) { printf("\n\t\t"); system("pause"); system("cls"); } else system("cls"); } }
上傳時間: 2020-06-11
上傳用戶:ccccy
#include<iostream> using namespace std; int s=0; int prime(int x){ int i,p=1; for(i=2;i<=x/2;i++){ if(x%i==0){ p=0; break; } } if(p!=0){ cout<<x<< " "; s++; } } int main(){ for (int k=5;k<=100;k++){ prime(k); if(s%5==0) cout<<'\n'; } return 0; }
標(biāo)簽: C++
上傳時間: 2020-06-30
上傳用戶:1274636550
--stdafx.h中沒有函數(shù)庫,只是定義了一些環(huán)境參數(shù),使得編譯出來的程序能在32位的操作系統(tǒng)環(huán)境下運行。 windows和mfc的include文件都非常大,即使有一個快速的處理程序,編譯程序也要花費相當(dāng)長的時間來完成工作。由于每個.cpp文件都包含相同的include文件,為每個.cpp文件都重復(fù)處理這些文件就顯得很傻了。 為避免這種浪費,appwizard和visualc++編譯程序一起進行工作,如下所示: --appwizard建立了文件stdafx.h,該文件包含了所有當(dāng)前工程文件需要的mfcinclude文件。且這一文件可以隨被選擇的選項而變化。 --appwizard然后就建立stdafx.cpp。這個文件通常都是一樣的。 --然后appwizard就建立起工程文件,這樣第一個被編譯的文件就是stdafx.cpp。 --當(dāng)visualc++編譯stdafx.cpp文件時,它將結(jié)果保存在一個名為stdafx.pch的文件里。(擴展名pch表示預(yù)編譯頭文件。) --當(dāng)visualc++編譯隨后的每個.cpp文件時,它閱讀并使用它剛生成的.pch文件。visualc++不再分析windowsinclude文件,除非你又編輯了stdafx.cpp或stdafx.h。 在這個過程中你必須遵守以下規(guī)則: --你編寫的任何.cpp文件都必須首先包含stdafx.h。 --如果你有工程文件里的大多數(shù).cpp文件需要.h文件,順便將它們加在stdafx.h(后部)上,然后預(yù)編譯stdafx.cpp。 --由于.pch文件具有大量的符號信息,它是你的工程文件里最大的文件。 如果你的磁盤空間有限,你就希望能將這個你從沒使用過的工程文件中的.pch文件刪除。執(zhí)行程序時并不需要它們,且隨著工程文件的重新建立,它們也自動地重新建立。
標(biāo)簽: stdafx
上傳時間: 2021-05-19
上傳用戶:1155
STM32F407VGT6精確脈沖控制步進電機源碼,采用STM32F407VGT6芯片,拋棄單脈沖輸出方式,直接使用普通PWM輸出方式精確輸出脈沖個數(shù),每個脈沖都可以改變頻率和占空比。PWM+中斷,簡單粗暴。#include "sys.h"#include "delay.h"#include "pwm1.h"#include "pwm2.h"#include "pwm3.h"//注釋見pwm1.c文件extern int count2;int main(void){ delay_init(168); //初始化延時函數(shù) TIM2_Init(1,167); TIM3_Init(1,167); TIM5_Init(1,167); // delay_ms(1000); TIM2_OUTPUT(); TIM3_OUTPUT(); TIM5_OUTPUT(); while(1) { //TIM2每次輸出完10個脈沖后間隔100ms再次輸出 if(count2 >= 10){ delay_ms(100); TIM2_OUTPUT(); } }
標(biāo)簽: stm32f407vgt6 脈沖控制 步進電機
上傳時間: 2021-10-26
上傳用戶:xsr1983
include<reg52.h> #define uint unsigned int #define uchar unsigned char uint temp,aa,wang,qian,bai,shi,ge; sbit dula=P2^6; sbit wela=P2^7; uchar code table[]={ 0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71}; void display( uint wang,uint qian,uint bai,uint shi,uint ge); void delay(uint z); void init(); void main() { init();//初始化子程序 while(1) { if(aa==20) { aa=0; temp++; if(temp==99999) { temp=0; } wang=temp/10000; qian=(temp-wang*10000)/1000; bai=(temp-wang*10000-qian*1000)/100; shi=(temp-wang*10000-qian*1000-bai*100)/10; ge=temp%10; } display(wang,qian, bai,shi,ge); } } void delay(uint z) { uint x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); } void display(uint wang,uint qian,uint bai,uint shi,uint ge) { dula=1; P0=table[wang]; dula=0; P0=0xff; wela=1; P0=0xfe; wela=0; delay(1); dula=1; P0=table[qian]; dula=0; P0=0xff; wela=1; P0=0xfd; wela=0; delay(1); dula=1; P0=table[bai]; dula=0; P0=0xff; wela=1; P0=0xfb; wela=0; delay(1); dula=1; P0=table[shi]; dula=0; P0=0xff; wela=1; P0=0xf7; wela=0; delay(1); dula=1; P0=table[ge]; dula=0; P0=0xff; wela=1; P0=0xef; wela=0; delay(1); } void init() { wela=0; dula=0; temp=0; TMOD=0x01; TH0=(65536-50000)/256; TL0=(65536-50000)%256; EA=1; ET0=1; TR0=1; } void timer0() interrupt 1 { TH0=(65536-50000)/256; TL0=(65536-50000)%256; aa++; } include<reg52.h> #define uint unsigned int #define uchar unsigned char uint temp,aa,wang,qian,bai,shi,ge; sbit dula=P2^6; sbit wela=P2^7; uchar code table[]={ 0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71}; void display( uint wang,uint qian,uint bai,uint shi,uint ge); void delay(uint z); void init(); void main() { init();//初始化子程序 while(1) { if(aa==20) { aa=0; temp++; if(temp==99999) { temp=0; } wang=temp/10000; qian=(temp-wang*10000)/1000; bai=(temp-wang*10000-qian*1000)/100; shi=(temp-wang*10000-qian*1000-bai*100)/10; ge=temp%10; } display(wang,qian, bai,shi,ge); } } void delay(uint z) { uint x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); } void display(uint wang,uint qian,uint bai,uint shi,uint ge) { dula=1; P0=table[wang]; dula=0; P0=0xff; wela=1; P0=0xfe; wela=0; delay(1); dula=1; P0=table[qian]; dula=0; P0=0xff; wela=1; P0=0xfd; wela=0; delay(1); dula=1; P0=table[bai]; dula=0; P0=0xff; wela=1; P0=0xfb; wela=0; delay(1); dula=1; P0=table[shi]; dula=0; P0=0xff; wela=1; P0=0xf7; wela=0; delay(1); dula=1; P0=table[ge]; dula=0; P0=0xff; wela=1; P0=0xef; wela=0; delay(1); } void init() { wela=0; dula=0; temp=0; TMOD=0x01; TH0=(65536-50000)/256; TL0=(65536-50000)%256; EA=1; ET0=1; TR0=1; } void timer0() interrupt 1 { TH0=(65536-50000)/256; TL0=(65536-50000)%256; aa++; } include<reg52.h> #define uint unsigned int #define uchar unsigned char uint temp,aa,wang,qian,bai,shi,ge; sbit dula=P2^6; sbit wela=P2^7; uchar code table[]={ 0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71}; void display( uint wang,uint qian,uint bai,uint shi,uint ge); void delay(uint z); void init(); void main() { init();//初始化子程序 while(1) { if(aa==20) { aa=0; temp++; if(temp==99999) { temp=0; } wang=temp/10000; qian=(temp-wang*10000)/1000; bai=(temp-wang*10000-qian*1000)/100; shi=(temp-wang*10000-qian*1000-bai*100)/10; ge=temp%10; } display(wang,qian, bai,shi,ge); } } void delay(uint z) { uint x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); } void display(uint wang,uint qian,uint bai,uint shi,uint ge) { dula=1; P0=table[wang]; dula=0; P0=0xff; wela=1; P0=0xfe; wela=0; delay(1); dula=1; P0=table[qian]; dula=0; P0=0xff; wela=1; P0=0xfd; wela=0; delay(1); dula=1; P0=table[bai]; dula=0; P0=0xff; wela=1; P0=0xfb; wela=0; delay(1); dula=1; P0=table[shi]; dula=0; P0=0xff; wela=1; P0=0xf7; wela=0; delay(1); dula=1; P0=table[ge]; dula=0; P0=0xff; wela=1; P0=0xef; wela=0; delay(1); } void init() { wela=0; dula=0; temp=0; TMOD=0x01; TH0=(65536-50000)/256; TL0=(65536-50000)%256; EA=1; ET0=1; TR0=1; } void timer0() interrupt 1 { TH0=(65536-50000)/256; TL0=(65536-50000)%256; aa++; }
標(biāo)簽: 矩陣式鍵盤
上傳時間: 2021-12-18
上傳用戶:2590813506
The PW4055 is a complete constant-current /constant-voltage linear charger for single cell lithiumion batteries.Its ThinSOT package and low external component count make the PW4055 ideallysuited for portable applications.Furthermore, the PW4055 is specifically designed to work within USBpower specifications.The PW4055 No external sense resistor is needed, and no blocking diode is required due to theinternal MOSFET architecture.Thermal feedback regulates the charge current to limit the dietemperature during high power operation or high ambient temperature. The charge voltage is fixedat 4.2V, and the charge current can be programmed externally with a single resistor. The PW4055automatically terminates the charge cycle when the charge current drops to 1/10th the programmedvalue after the final float voltage is reached. When the input supply (wall adapter or USB supply) isremoved, the PW4055 automatically enters a low current state, dropping the battery drain currentto less than 2μA. The PW4055 can be put into shutdown mode, reducing the supply current to 25μA.The BAT pin has a 7KV ESD(HBM) capability. Other features include charge current monitor, undervoltage lockout, automatic recharge and a status pin to indicate charge termination and the presenceof an input voltage
標(biāo)簽: pw4055
上傳時間: 2022-02-11
上傳用戶:jason_vip1
Agilent 34401A Service Guide.pdfIEC Measurement Category II includes electrical devices connected to mains at an outlet on a branch circuit. Such devices include most small appliances, test equipment, and other devices that plug into a branch outlet or socket. The 34401A may be used to make measurements with the HI and LO inputs connected to mains in such devices, or to the branch outlet itself (up to 300 VAC). However, the 34401A may not be used with its HI and LO inputs connected to mains in permanently installed electrical devices such as the main circuit-breaker panel, sub-panel disconnect boxes, or permanently wired motors. Such devices and circuits are subject to overvoltages that may exceed the protection limits of the 34401A. Note: Voltages above 300 VAC may be measured only in circuits that are isolated from mains. However, transient overvoltages are also present on circuits that are isolated from mains. The Agilent 34401A are designed to safely withstand occasional transient overvoltages up to 2500 Vpk. Do not use this equipment to measure circuits where transient overvoltages could exceed this level. Additional Notices Waste Electrical and Electronic Equipment (WEEE) Directive 2002/96/EC This product complies with the WEEE Directive (2002/96/EC) marking requirement. The affixed product label (see below) indicates that you must not discard this electrical/electronic product in domestic household waste. Product Category: With reference to the equipment types in the WEEE directive Annex 1, this product is classified as a "Monitoring and Control instrumentation" product. Do not dispose in domestic household waste. To return unwanted products, contact your local Agilent office, or see www.agilent.com/environment/product for more information. Agilent 34138A Test Lead Set The Agilent 34401A is compatible with the Agilent 34138A Test Lead Set described below. Test Lead Ratings Test Leads - 1000V, 15A Fine Tip Probe Attachments - 300V, 3A Mini Grabber Attachment - 300V, 3A SMT Grabber Attachments - 300V, 3A Operation The Fine Tip, Mini Grabber, and SMT Grabber attachments plug onto the probe end of the Test Leads. Maintenance If any portion of the Test Lead Set is worn or damaged, do not use. Replace with a new Agilent 3413
標(biāo)簽: agilent
上傳時間: 2022-02-20
上傳用戶:
This Getting Started Guide is written for Maxwell beginners and experienced users who would like to quickly re familiarize themselves with the capabilities of MaxwelL.This guide leads you step-by-step through solving and analyzing the results of a rotational actuator magnetostatic problem with motion By following the steps in this guide, you will learn how to perform the following tasks Modify a models design parameters y Assign variables to a model's design parameters.Specify solution settings for a design Validate a designs setupRun a maxwell simulation v Plot the magnetic flux density vecto v include motion in the simulation本《入門指南》是為希望快速重新熟悉MaxwelL功能的Maxwell初學(xué)者和有經(jīng)驗的用戶編寫的。本指南將引導(dǎo)您逐步解決和分析旋轉(zhuǎn)致動器靜運動問題的結(jié)果。按照本指南中的步驟,您將學(xué)習(xí)如何執(zhí)行以下任務(wù)。修改模型設(shè)計參數(shù)y將變量分配給模型的設(shè)計參數(shù)。指定設(shè)計的解決方案設(shè)置驗證設(shè)計設(shè)置運行maxwell模擬v繪制磁通密度vecto v在模擬中包含運動
上傳時間: 2022-03-10
上傳用戶:
電子書-十天學(xué)會單片機實例100.pdf//實例 4:用單片機控制一個燈閃爍:認(rèn)識單片機的工作頻率 #include<reg51.h> //包含單片機寄存器的頭文件 /**************************************** 函數(shù)功能:延時一段時間 *****************************************/ void delay(void) //兩個 void 意思分別為無需返回值,沒有參數(shù)傳遞 { unsigned int i; //定義無符號整數(shù),最大取值范圍 65535 for(i=0;i<20000;i++) //做 20000 次空循環(huán) ; //什么也不做,等待一個機器周期 } /******************************************************* 函數(shù)功能:主函數(shù) (C 語言規(guī)定必須有也只能有 1 個主函數(shù)) ********************************************************/ void main(void) { while(1) //無限循環(huán) { P1=0xfe; //P1=1111 1110B, P1.0 輸出低電平 delay(); //延時一段時間 P1=0xff; //P1=1111 1111B, P1.0 輸出高電平 www.91
標(biāo)簽: 單片機
上傳時間: 2022-03-19
上傳用戶:kingwide
HX711_1Kg#include "HX711.h"float Weight = 0;void setup(){ Init_Hx711(); //初始化HX711模塊連接的IO設(shè)置 Serial.begin(9600); Serial.print("Welcome to use!\n"); delay(3000); Get_Maopi(); //獲取毛皮}void loop(){ Weight = Get_Weight(); //計算放在傳感器上的重物重量 Serial.print(float(Weight/1000),3); //串口顯示重量 Serial.print(" kg\n"); //顯示單位 Serial.print("\n"); //顯示單位 delay(1000); //延時1s}
上傳時間: 2022-03-20
上傳用戶:
蟲蟲下載站版權(quán)所有 京ICP備2021023401號-1