① 匯編想輸出數字卻輸出亂碼
你這個語句的功能是輸出字元串,但是你需要自己設置字元串的地址,ds:dx=字元串的地址,而且這個字元串還要以$結束。目前亂碼是應該是指向了一個未知的地方導致的。
下面的代碼因為沒有編譯環境,因此未做驗證,僅做參考
assume
cs:cseg,ds:dseg
dseg
segment
db
'test$'
dseg
ends
cseg
segment
start:
mov
ax,dseg
mov
ds,ax
mov
dx,0
mov
ah,9
int
21h
cseg
ends
end
start
② C++ 使用模板函數,分別對整型、單精度、雙精度的數據排序。 編譯連接都沒問題,為什麼結果有亂碼
那不是亂碼,是輸出間隔太小,把較長的數據連到一起了。提供兩個措施供參考:
把輸出間隔變大。
控制小數點位數。
③ c語言幫忙改錯 插入編譯連接無問題但結果是亂碼
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//主函數
#defineSIZEsizeof(structstu_node)
structstu_node{
intnum;
charname[20];
intscore;
structstu_node*next;
};
intn; //n表示表中節點的個數
structstu_node*Init_stu();//鏈表初始化
structstu_node*create_stu(); //按輸入順序建立單向鏈表
voidprint_stu(structstu_node*head); //遍歷
voidinsert_stu(structstu_node*head,structstu_node*s);//插入
intdelete_stu(structstu_node*head,intnum);//刪除
intmain(){
structstu_node*p,*head=Init_stu();
intchoice,num;
do{
printf("請選擇菜單(0-4): ");
printf(" 1.建立鏈表 2.插入 3.刪除 4.遍歷 0.退出 ");
scanf("%d",&choice);
if(choice>1&&head->next==NULL){
printf("鏈表尚未建立,請先選擇1。 ");
break;
}
switch(choice){
case0:break;
case1:head=create_stu();break;
case2:printf("請輸入待插入的學生信息: ");
// p=(structstu_node*)malloc(n*SIZE);
p=(structstu_node*)malloc(SIZE);
scanf("%d%s%d",&p->num,p->name,&p->score);
insert_stu(head,p);
free(p);
break;
case3:printf("請輸入待刪除的學生學號:");
scanf("%d",&num);
delete_stu(head,num);
break;
case4:print_stu(head);
default:printf("不能識別的選擇:%d,請重新選擇。 ",choice);
break;
}
}while(choice);
return0;
}
structstu_node*Init_stu(){
structstu_node*head=(structstu_node*)malloc(sizeof(SIZE));
if(head==NULL){
printf("內存分配失敗! ");
returnNULL;
}
head->next=NULL;
returnhead;
}
//建立鏈表
structstu_node*create_stu(structstu_node*head){
structstu_node*p=head;
n=0;
intnum,score;
charname[20];
printf("請輸入學號姓名成績(學號為0時停止輸入): ");
scanf("%d%s%d",&num,name,&score);
while(num){
p->next=(structstu_node*)malloc(SIZE);
p->next->num=num;
p->next->score=score;
strcpy(p->next->name,name);
p=p->next;
n++;
};
p->next=NULL;
returnhead;
}
//遍歷鏈表
voidprint_stu(structstu_node*head){
structstu_node*p;
p=head->next;
if(head->next==NULL){
printf("空表,無記錄 ");
return;
}
printf(" 學號 姓名 成績 ");
while(p){
printf("%4d %s %d ",p->num,p->name,p->score);
p=p->next;
}
}
//插入
voidinsert_stu(structstu_node*head,structstu_node*s){
s->next=head->next;//直接插在頭部作為鏈表的首節點
head->next=s;
}
//刪除
intdelete_stu(structstu_node*head,intnum){
structstu_node*p=head,*q;
if(p->next==NULL){
printf("鏈表為空!刪除操作失敗! ");
return0;
}
while(p->next){
if(num==p->num){
q=p->next;
p=p->next;
free(q);
return1;
--n;
}
p=p->next;
}
printf("%d,表中無此節點! ",num);
return0;
}
④ 怎麼編譯前漢字顯示正常,編譯後就變成亂碼了
你好,這個問題的原因主要在編碼問題上,你可以在設置-編輯器中更改一下編碼,如果你是Windows
Xp的話,請選擇windows-936,找准對應的編碼就行了。
或者直接更改菜單欄中的編輯-文件編碼-系統默認,不過這種修改方法,需要每次編程時都要更改設置才行。
⑤ 數據結構數制的轉換,程序編譯正確,可是輸出是亂碼。怎麼辦
{
a[j]=n%2;
n=n/2;
m++;//這里不應該也要有j++嗎 再來個j++看看
}
⑥ JAVA 編譯能通過,但顯示亂碼
不太明白你的亂碼是指的什麼,單從程序看 你的代碼是沒問題的,可能是你其他環境影響,最好有截圖
⑦ 如何解決VC++編譯後出現數字亂碼
情況1:可能是因為語言設置不正確。如果想在AppWizard生成的工程文件中使用中文,在在MFC AppWizard的第1步中選擇中文資源,選擇Chinese(P.R.C),如果你在語言列表中沒有找到有關中文的選項,說明你的VC++的中文支持模塊沒有安裝。此時,應退出VC++,在VC++的光碟的DevStudioSharedIDEBinIDE目錄下找到APPWZCHS.DLL文件,將其拷貝到硬碟的DevStudioSharedIDEBinIDE目錄下即可,再啟動VC++,就可以看到這一選項了。使用這一選項生成的工程文件中的所有資源都是中文的。VC++還提供了繁體中文(APPWZCHT.DLL)、日文(APPWZJPN.DLL)和韓文(APPWZKOR.DLL)的支持模塊。
這種情況就是語言設置問題,與本身無關
情況2: 如果你的工程中的菜單、對話框、字元串等資源不是由AppWizard生成的,而是手工添加的,你必須保證該資源的Language選項為Chinese(P.R.C)。具體的做法是在資源列表中選擇資源,然後在快捷菜單中選擇Properties,在話框中設置Language下拉框。如果在Language中選擇English,盡管在集成環境中可以正常顯示中文,但編譯後就變成了諸如"___.???"之類的亂碼了。
情況3:方法1: 有一個解決方案不必從頭作起:找到rc文件(資源文件),把其中LANGUAGE 9, 1的地方改為4,2;codepage(1252)改為codepage(936);另外把#include "afxres.rc" 改成#include "l.chsafxres.rc";把"afxres.rc" 改成"l.chs\afxres.rc"即可,其中的數據根據不同文字代碼可能不同。
希望能夠幫到你!
【參考資料:網路經驗】
⑧ c語言編譯運行亂碼是什麼原因
這種情況多數是由於操作系統的語言選項不正確引起的。建議你查看一下控制面板中的區域和語言選項,特別是有關「非Unicode程序的語言」,一定要選擇成「中文(簡體,中國)」。然後重啟電腦。
⑨ c語言代碼編譯通過,但輸出時有亂碼,什麼原因
修改如下:
//---------------------------------------------------------------------------
#include<stdio.h>
void main()
{
void secret(char str1[],char str2[]); /*注意這里*/
char str1[10],str2[10]={0}; /*注意這里*/
int i;
printf("please input something");
gets(str1);
secret(str1,str2); /*注意這里*/
puts(str2); /*注意這里*/
}
void secret(char str1[],char str2[]) /*注意這里*/
{ int i;
for(i=0;i<10&&(str1[i])!=0;i++)
{
if (str1[i]<='z'&&str1[i]>='a')
str2[i]='0';
else
if (str1[i]<='Z'&&str1[i]>='A')
str2[i]='1';
else
if (str1[i]<='9'&&str1[i]>='0')
str2[i]='2';
else
if (str1[i]==' ')
str2[i]='3';
else
str2[i]='4';
}
/*注意這里*/
}
//---------------------------------------------------------------------------