編程問題囊
① 簡單編程問題
#include <stdio.h>
int main()
{
int x,y;
x=3;
y=x*x;
printf("%d = %d * %d ", y,x,x);
printf("%d * %d = %d ", x,x,y);// 輸出
return 0;
}
② c語言編程問題(急)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct student
{
char name[10];
char number[10];
int b[3];
};
int average(struct student *p)
{
int i;
for(i=0;i<=9;i++)
printf("average is%4d\n",((p+i)->b[0]+(p+i)->b[1]+(p+i)->b[2])/3);
}
int highest(struct student *p)
{
int i,j,high=0;//這里要聲明一下'j'你沒有聲明
float avg;//平均值要用除法,最好是浮點型。
avg=(p->b[0]+p->b[1]+p->b[2])/3;
for(i=0;i<=9;i++)
{
if(avg<((p+i)->b[0]+(p+i)->b[1]+(p+i)->b[2])/3)
{
avg=((p+i)->b[0]+(p+i)->b[1]+(p+i)->b[2])/3;
j=i;
}
}
printf("%4s %4s %4f %4d %4d %4d\n",p[j].name,p[j].number,avg,p[j].b[0],p[j].b[1],p[j].b[2]);
//注意這里的輸出格式控制,name, number都是字元數組,不應該為%d,不然輸出來讓人看不懂
}
int main()
{
struct student a[10];
int i;
for(i=0;i<10;i++)//這里只有10個值,注意邊界,還有數組的起始下標為0
{
printf("input name number\n");
scanf("%s %s",&a[i].name,&a[i].number);
printf("input 1 2 3\n");
scanf("%d %d %d",&a[i].b[0],&a[i].b[1],&a[i].b[2]);
}
highest(a);
average(a);
}
你的思維邏輯是正確的,只是編程風格實在不好。
③ 簡單的編程問題
回答:
問題1:
int fact(int n) //for語句
{
int i,TempInt=1;
for(i=2;i<=n;i++)
TempInt*=i;
return TempInt;
}
int fact(int n) //while語句
{
int i=2,TempInt=1;
while(i<=n)
{
TempInt*=i++;
}
return TempInt;
}
問題2
int max(int a,int b,int c)
{
int d=a;
if(d<b) d=b;
if(d<c) d=c;
return d;
}
int min(int a,int b,int c)
{
int d=a;
if(d>b) d=b;
if(d>c) d=c;
return d;
}
問題3.2
float pow(float a,int n)
{
int i,tn;
float tp=1;
if(n<0)
{
for(i=1;i<=-n;i++)
tp*=a;
if(tp!=0) return 1/tp;
}
if(n>0)
{
for(i=1;i<=n;i++)
tp*=a;
return tp;
}
return 1;
}
④ 編程的問題
C語言也就是編程的基礎!只要學好C就OK!以後學習其他語言也很簡單!其實都和C也是大同小異!
學習編程就從C學起!掌握好C語言的重點:數據類型,控制語句,指針,結構體等(我建議學點英語會更好)這樣對你編程也有很大的幫助!
沒英語基礎學起來有些知識點不是那麼好記憶~~~~···(我是學軟體開發的,學了一年多了·這是我的的總結)
祝你成功!!!
⑤ 關於編程問題
你在結束前加一個readln語句。就會等你打了一個回車後再回到編程界面:
Program lx;
var r,c,y:integer;
begin
writeln('請輸入密碼');
write('r=');
readln(r);
write('c=');
readln(c);
write('y=');
readln(y);
if (r=1998)and(c=09)and(y=17) then write('歡迎')
else write('r=1998,c=09,y=17');
readln;
end.
⑥ 關於編程的問題!
VB 非常齊全的資料
手冊與指南
VB.Net與ASP.Net代碼手冊
http://download.chinaitlab.com/soft/10468.htm
VB 6.0中文版語言參考手冊
http://download.chinaitlab.com/soft/10467.htm
VB編程經驗手冊
http://download.chinaitlab.com/soft/9412.htm
VB API 函數使用手冊
http://download.chinaitlab.com/soft/9308.htm
VBA高級開發手冊
http://download.chinaitlab.com/soft/9307.htm
VB速查手冊之技巧篇
http://download.chinaitlab.com/soft/9306.htm
VB與VBA技術手冊
http://download.chinaitlab.com/soft/9305.htm
VB.NET Remoting 技術手冊
http://download.chinaitlab.com/soft/9146.htm
VB.Net調試技術手冊
http://download.chinaitlab.com/soft/9145.htm
VB.Net字元串和正則表達式參考手冊
http://download.chinaitlab.com/soft/9137.htm
VBScript語言參考
http://download.chinaitlab.com/soft/7915.htm
VB6程序設計參考手冊
http://download.chinaitlab.com/soft/7599.htm
VB技巧問答10000例
http://download.chinaitlab.com/soft/6694.htm
VB5 開發WEB資料庫指南
http://download.chinaitlab.com/soft/6181.htm
VBscript英文幫助手冊
http://download.chinaitlab.com/soft/5950.htm
VB6控制項參考手冊
http://download.chinaitlab.com/soft/5946.htm
VB6語言參考手冊
http://download.chinaitlab.com/soft/5947.htm
VB6程序員指南
http://download.chinaitlab.com/soft/5944.htm
VB 5開發WEB資料庫指南
http://download.chinaitlab.com/soft/4702.htm
VBA 高級開發指南
http://download.chinaitlab.com/soft/4604.htm
VB中文版實用參考手冊
http://download.chinaitlab.com/soft/3682.htm
VB編程經驗手冊
http://download.chinaitlab.com/soft/2161.htm
VB6組件工具指南
http://download.chinaitlab.com/soft/1752.htm
Visual Basic API函數參考手冊
http://download.chinaitlab.com/soft/9843.htm
Visual Basic 6.0中文版實用參考手冊
http://download.chinaitlab.com/soft/9398.htm
Vsual Basic 6.0 控制項參考手冊
http://download.chinaitlab.com/soft/9288.htm
Visual Basic.NET 串列化參考手冊
http://download.chinaitlab.com/soft/9241.htm
Visual Basic.net 反射參考手冊
http://download.chinaitlab.com/soft/9240.htm
Visual Basic.NET類設計手冊
http://download.chinaitlab.com/soft/9235.htm
Visual Basic.net線程參考手冊
http://download.chinaitlab.com/soft/9126.htm
Visual Basic編程經驗手冊
http://download.chinaitlab.com/soft/7975.htm
Visual Basic.Net專家指南
http://download.chinaitlab.com/soft/10311.htm
Visual Basic.NET編程指南
http://download.chinaitlab.com/soft/9841.htm
Visual Basic 6.0 組件工具指南
http://download.chinaitlab.com/soft/7602.htm
其它相關資源
VBSCRIPT函數方法速查
http://download.chinaitlab.com/soft/6158.htm
VBScript學習
http://download.chinaitlab.com/soft/5949.htm
VB學習一點通 V1.0
http://download.chinaitlab.com/soft/5762.htm
Access 2003 VBA 程序員參考書
http://download.chinaitlab.com/soft/5293.htm
VB、C快速進階 V3.0
http://download.chinaitlab.com/soft/4735.htm
VB系統資源
http://download.chinaitlab.com/soft/4701.htm
VB Script語言參考
http://download.chinaitlab.com/soft/4451.htm
VB編程技巧集
http://download.chinaitlab.com/soft/3882.htm
VBScript 教程及語言參考
http://download.chinaitlab.com/soft/3881.htm
VBScript與JScript實例教程
http://download.chinaitlab.com/soft/2639.htm
VB Script基礎
http://download.chinaitlab.com/soft/2160.htm
VBScript 幫助手冊
http://download.chinaitlab.com/soft/2135.htm
VB常用函數
http://download.chinaitlab.com/soft/1753.htm
VB精華文摘
http://download.chinaitlab.com/soft/1269.htm
Visual Basic 術語解釋
http://download.chinaitlab.com/soft/10677.htm
Visual Basic 常用數值演算法集
http://download.chinaitlab.com/soft/9301.htm
Visual Basic 第三方控制項大全
http://download.chinaitlab.com/soft/9300.htm
Visual Basic 語言參考-函數速查
http://download.chinaitlab.com/soft/6244.htm
視頻相關:
VB.net多媒體教學
http://download.chinaitlab.com/soft/1567.htm
洪恩編程之道VB.NET
http://download.chinaitlab.com/soft/9559.htm
編程高手教程-VB
http://download.chinaitlab.com/soft/9180.htm
邊用邊學Visual Basic 6視頻教學
http://download.chinaitlab.com/search.asp?keywords=邊用邊學Visual%20Basic%206視頻教學&tt=3
程序設計基礎視頻教學
http://download.chinaitlab.com/search.asp?keywords=VB程序設計基礎視頻教學&tt=3
VB編程與應用視頻
http://download.chinaitlab.com/search.asp?keywords=VB編程與應用視頻&tt=3
VB.net 英文視頻教程
http://download.chinaitlab.com/search.asp?keywords=VB.net%20英文視頻教程&tt=3
⑦ 編程問題
讓我小松鼠來告訴你吧。
Option Base 1
我們知道,在VB中的數組不管是一維,二維還是三維,其默認的數組下界都為0。舉例來說,下面語句
Dim MyArray(2) AS Integer
聲明了一個名稱為MyArray的數組,類型為Integer,共有3個元素,這3個元素的下標范圍為0-2(默認下標下界從0開始)。就是說,MyArray數組的3個元素下標依次為MyArray(0),MyArray(1),MyArray(2)。可以看到,這種默認數組下標下界從0開始的方式很不符合人們的習慣。
為了使數組的使用符合人們的習慣,可以加入Option Base 1 語句告訴VB所定義的數組的下標下界從1開始而不是使用默認的從0開始。這樣,對上面MyArray數組的定義語句,
則應改為
Dim MyArray(3) AS Integer
這樣MyArray數組的下標范圍就變成了1-3,MyArray數組的3個元素下標依次為MyArray(1),MyArray(2),MyArray(3)。這時如果仍用MyArray(0)來訪問MyArray數組的第一個元素,運行時將發生下標越界的實時錯誤。
Option Explicit
在預設情況下,VB並不要求在使用變數時一定要先聲明該變數,這樣做看起來很方便,變數不用聲明就可以用來用去,但卻存在潛在的危險。例如我們使用了一個名為ABCD的變數來保存一個將要使用的值,而在要使用該變數的值的地方我們誤將ABCD變數名輸入成ABC,這時系統在不經任何提示的情況下會認為又出現了一個新變數。這種錯誤一旦發生,將很難檢查出來。對變數不加聲明就使用,是一種極為糟糕的編程方法。
加入Option Explicit語句後,系統就會要求在程序中使用的任何變數都必須先聲明。如果在程序中使用了未經聲明的變數,在程序運行後會彈出消息框提醒程序編寫者。
怎麼樣,你理解了嗎。
⑧ 初學編程的人一般會遇到的幾個問題
對於一個初學編程的人來說,首先遇到的問題就是:(1)、在編寫源程序過程中出現的各種語法錯誤。這種錯誤主要是由於剛剛開始學習編程,對編程語言的語句、以及語法結構還不是很清晰造成的,這種錯誤是最容易進行調試的,因為語法錯誤,編譯器連編譯都無法通過;(2)、當對初始編程較為熟練了、且語法錯誤較少了之後,之後就會遇到更為復雜、並且難於調試的語義錯誤。例如在 C 語言中,對於如下代碼:
void main( )
{
int n ;
scanf("%d", &n) ;
if( n == 100)
printf(" n is 100 !\n") ;
else
printf(" n is not 100 !\n") ;
}
在邏輯判斷語句:if( n == 100) 中,如果誤將「==」(邏輯等於)寫成了「=」(賦值等於),那麼在 scanf("%d", &n) 語句中,無論你輸入的 n 等於多少,一旦執行 if 語句,那麼 將 100 這個數字賦給變數 n,則該邏輯表達式的值總是 1,程序的運行結果必定總是輸出:n is 100。
而該程序的實際思路是:從鍵盤輸入一個整數,如果該整數等於 100,則輸出:n is 100 !
如果輸入的整數不等於 100 的話,則輸出:n is not 100 !
像這樣的邏輯錯誤(在編譯源程序時,C 語言編譯器是檢查不出來的),如果沒有豐富的程序調試經驗,程序調試起來就是非常困難的。
所以說,如果想學習編程,必須要勤於上機編輯、調試、運行程序,而不能夠只是在書本上閱讀程序。只有這樣,才能夠在較短的時間內,使自己的編程水平有一個較大的提高。