編程檢驗
⑴ 編程實現檢驗括弧是否匹配
#include <stdio.h>
char stack[100];
int top=-1;
void push(char ch)
{
stack[++top]=ch;
}
char pop()
{
if(top<-1)
{
top--;
return '\0';
}
else
{
return stack[top--];
}
}
int main(void)
{
char c[20];
int i=0;
char ch;
gets(c);
while(c[i] != '\0')
{
if(c[i] == '(')
push(c[i]);
if(c[i] == ')')
{
ch=pop();
if(ch=='\0')
break;
}
i++;
}
if(top == -1)
printf("right");
else
printf("wrong");
return 0;
}
⑵ vb 大神!假如text中有1,2,3,4,5,6,7,8,8。怎麼設置編程檢驗8的個數占總個數的
Dim a() As String
a = Split(Text1.Text, ",")
MsgBox "8在Text1中的個數占總個數的百分比為:" & Format((UBound(Filter(a, "8")) + 1) / (UBound(a) + 1), "0.00%")
⑶ 如何檢驗自己是否已經掌握一門編程語言
從應用上來說:學習語言一定要做東西,最好自己多做一些項目。。。
從理論上來看:沒有人敢說能完全掌握一門語言,高級編程語言之間基本是互通的,主要是編程的思想。學習語言要從該語言的特性下手,如java 面向對象,跨平台,多態。。。等
綜上語言基礎不難,復雜的是演算法實現
自我簡單總結了一下一門語言所包含的基礎內容,可以通過下面這些條目自查:
1基本語法
--1.1注釋
--1.2輸入輸出
--1.3變數、常量
--1.4運算符
--1.5控制結構
--1.6異常處理
2常用函數
--2.1函數定義
--2.2日期函數
--2.3字元串處理函數
--2.4數學函數
3類
--3.1繼承封裝
--3.2公有私有
--3.3多態
--3.4模塊化
4資料庫、文件
--4.1讀
--4.2寫
--4.3查詢語句優化
5數據結構
--5.1數組
--5.2鏈表
--5.3堆棧
--5.4哈希
--5.5圖
6圖形處理
7性能
--7.1效率
--7.2負載
--7.3優化
8安全
--8.1防攻擊
--8.2防盜鏈
--8.3防竊取
9業務
--9.1需求分析
--9.2模型構建
--9.3系統架構
--9.4模塊劃分
⑷ c語言中常量88在內存中的存儲形式為58H。請問怎麼用編程來檢驗,就是編寫一個程序
#include<stdio.h>
int main()
{
printf("0x%x\n",88);
return 0;
}
⑸ 自動編程時,可以通過什麼檢驗加工軌跡是否合理
自動編程時,可以通過檢查刀具軌跡的正確性來檢驗加工軌跡是否合理。證模塊指通過模擬加工過程來檢驗加工中是否過切,刀具與約束面是否發生干涉與碰撞等;模擬模塊是將加工過程中的零件模型、機床模型、夾具模型及刀具模型用圖形動態顯示出來,基本具有試切加工的效果。
⑹ C#編程 想實現一個檢驗MD5的值來檢驗文件的目的。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Security.Cryptography;
namespace 文件處理
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void Form3_Load(object sender, EventArgs e)
{
//獲取了他的MDS值
MessageBox.Show(MD5File(@"C:\Documents and Settings\Administrator\桌面\temp\my.doc"));
}
/// <summary>
/// 計算文件的 MD5 值
/// </summary>
/// <param name="fileName">要計算 MD5 值的文件名和路徑</param>
/// <returns>MD5 值16進制字元串</returns>
public string MD5File(string fileName)
{
return HashFile(fileName, "md5");
}
/// <summary>
/// 計算文件的哈希值
/// </summary>
/// <param name="fileName">要計算哈希值的文件名和路徑</param>
/// <param name="algName">演算法:sha1,md5</param>
/// <returns>哈希值16進制字元串</returns>
public string HashFile(string fileName, string algName)
{
if (!System.IO.File.Exists(fileName))
return string.Empty;
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
byte[] hashBytes = HashData(fs, algName);
fs.Close();
return ByteArrayToHexString(hashBytes);
}
/// <summary>
/// 計算哈希值
/// </summary>
/// <param name="stream">要計算哈希值的 Stream</param>
/// <param name="algName">演算法:sha1,md5</param>
/// <returns>哈希值位元組數組</returns>
public byte[] HashData(Stream stream, string algName)
{
HashAlgorithm algorithm;
if (algName == null)
{
throw new ArgumentNullException("algName 不能為 null");
}
if (string.Compare(algName, "sha1", true) == 0)
{
algorithm = SHA1.Create();
}
else
{
if (string.Compare(algName, "md5", true) != 0)
{
throw new Exception("algName 只能使用 sha1 或 md5");
}
algorithm = MD5.Create();
}
return algorithm.ComputeHash(stream);
}
/// <summary>
/// 位元組數組轉換為16進製表示的字元串
/// </summary>
/// <param name="buf"></param>
/// <returns></returns>
public string ByteArrayToHexString(byte[] buf)
{
string returnStr = "";
if (buf != null)
{
for (int i = 0; i < buf.Length; i++)
{
returnStr += buf[i].ToString("X2");
}
}
return returnStr;
}
}
}
好好學習吧,小夥子!呵呵
