1. c語言編程題目!急.明天就要用!!!!!!!!!!!!!!!!
剛寫的,代碼如下:
#include<stdio.h>
#include<string.h>
#define N 20
struct stu
{
long num;
char name[20];
char sex;
float score[7];
} a[N];
void input(int p)
{
long tmpn;
char tmpc,tmps[20];
float tmp;
int i,j;
scanf("%ld",&tmpn);
a[p].num=tmpn;
scanf("%c",&tmpc);
j=0;
do
{
scanf("%c",&tmpc);
if (tmpc!=' ')
{
tmps[j]=tmpc;
tmps[j+1]='\0';
j++;
}
}
while (tmpc!=' ');
strcpy(a[p].name,tmps);
scanf("%c",&tmpc);
a[p].sex=tmpc;
a[p].score[5]=0;
for (i=0;i<5;i++)
{
scanf("%f",&tmp);
a[p].score[i]=tmp;
a[p].score[5]+=tmp;
}
a[p].score[6]=a[p].score[5]/5;
}
void swap(p)
{
int i;
long tmpn;
char tmps[20]={0};
float tmp;
tmpn=a[p].num;a[p].num=a[p+1].num;a[p+1].num=tmpn;
strcpy(tmps,a[p].name);strcpy(a[p].name,a[p+1].name);strcpy(a[p+1].name,tmps);
for (i=0;i<7;i++)
{
tmp=a[p].score[i];
a[p].score[i]=a[p+1].score[i];
a[p+1].score[i]=tmp;
}
}
void sort(p)
{
int i,j;
for (i=1;i<N;i++)
for (j=0;j<N-i;j++)
if (a[j].score[p]<a[j+1].score[p])
swap(j);
}
void printall()
{
int i,j;
printf("num name sex chn math eng phy che tot ave\n");
for (i=0;i<N;i++)
{
printf("%ld %s %c",a[i].num,a[i].name,a[i].sex);
for (j=0;j<7;j++)
printf(" %f",a[i].score[j]);
printf("\n");
}
}
void main()
{
int i,k;
printf("Student information system.\n");
printf("Input the %d students' information:\n",N);
printf("number name sex chinese maths english physics chemistry\n");
for (i=0;i<N;i++)
{
input(i);
printf("\n%d student(s) rest.\n",N-i-1);
}
do
{
printf("Completed!\n");
printf("Now sort.Please select a keyword as below:\n1\tchinese\n2\tmaths\n3\tenglish\n4\tphysics\n5\tchemistry\n6\ttotal\n0\tEXIT\n");
printf("Please input the number of the keyword you want to sort:");
scanf("%d",&k);
if (k)
{
sort(k-1);
printf("The result:\n");
printall();
}
}
while (k);
}
2. c語言簡單問題
#include<stdio.h>
inthasno(chars[],charc){
inti=0,flag=1;
while(s[i]&&flag){
flag=(s[i]!=c);
++i;
}
returnflag;
}
intmain(){
chars[256],t[256];
inti=0,res=0;
printf("第一個串:");
gets(s);
printf("第二個串:");
gets(t);
while(t[i]){
if(hasno(s,t[i]))++res;
++i;
}
printf("%s中共有%d個與%s不同的字元。
",s,res,t);
return0;
}
3. 什麼是C語言
C語言是在70年代初問世的。一九七八年由美國電話電報公司(AT&T)貝爾實驗室正式發表了C語言。同時由B.W.Kernighan和D.M.Ritchit合著了著名的「THE
C
PROGRAMMING
LANGUAGE」一書。通常簡稱為《K&R》,也有人稱之為《K&R》標准。但是,在《K&R》中並沒有定義一個完整的標准C語言,後來由美國國家標准學會在此基礎上制定了一個C
語言標准,於一九八三年發表。通常稱之為ANSI
C。
當代最優秀的程序設計語言
早期的C語言主要是用於UNIX系統。由於C語言的強大功能和各方面的優點逐漸為人們認識,到了八十年代,C開始進入其它操作系統,並很快在各類大、中、小和微型計算機上得到了廣泛的使用。成為當代最優秀的程序設計語言之一。
C語言的特點
C語言是一種結構化語言。它層次清晰,便於按模塊化方式組織程序,易於調試和維護。C語言的表現能力和處理能力極強。它不僅具有豐富的運算符和數據類型,便於實現各類復雜的數據結構。它還可以直接訪問內存的物理地址,進行位(bit)一級的操作。由於C語言實現了對硬體的編程操作,因此C語言集高級語言和低級語言的功能於一體。既可用於系統軟體的開發,也適合於應用軟體的開發。此外,C語言還具有效率高,可移植性強等特點。因此廣泛地移植到了各類各型計算機上,從而形成了多種版本的C語言。
C語言版本
目前最流行的C語言有以下幾種:
·Microsoft
C
或稱
MS
C
·Borland
Turbo
C
或稱
Turbo
C
·AT&T
C
這些C語言版本不僅實現了ANSI
C標准,而且在此基礎上各自作了一些擴充,使之更加方便、完美。
面向對象的程序設計語言
在C的基礎上,一九八三年又由貝爾實驗室的Bjarne
Strou-strup推出了C++。
C++進一步擴充和完善了C語言,成為一種面向
對象的程序設計語言。C++目前流行的最新版本是Borland
C++4.5,Symantec
C++6.1,和Microsoft
VisualC++
2.0。C++提出了一些更為深入的概念,它所支持的這些面向對象的概念容易將問題空間直接地映射到程序空間,為程序員提供了一種與傳統結構程序設計不同的思維方式和編程方法。因而也增加了整個語言的復雜性,掌握起來有一定難度。
C和C++
但是,C是C++的基礎,C++語言和C語言在很多方面是兼容的。因此,掌握了C語言,再進一步學習C++就能以一種熟悉的語法來學習面向對象的語言,從而達到事半功倍的目的。
4. C語言中什麼是間接運算符謝謝
指針運算就是一種間接運算;如 *p=&a ; *p+=1; 實現的是a+1
5. 大學必拿的幾個證書是什麼
在大學生活四年的時光里,好多人都會選擇在大學期間考一些證書,為自己以後的工作和生活增加一些光彩。可能是一直流傳這樣的一句話「證多不壓身」,同是也是為自己多幾條出路,下面就為大家整理了一些大學中,必拿的幾個證書!
NO.1:畢業證、學位證、第二學位
這是最最重要的證書,存在三點區別:一是名牌院校和普通院校的區別;二是熱門專業和冷門專業的區別;三是專科、本科、研究生的區別。專業背景是企業最最看重的,很多職位只給限定專業畢業同學面試機會。雖然說企業看重能力,而不是學歷,但名牌大學、熱門專業,就是一塊有分量的敲門磚,進得門里才有機會展現能力。

其實,大學期間應該還有很多證書需要拿。總之一句話,生存之道,多多益善但是掌握為主,不能不作用於實際,那到頭來還是一張廢紙,選擇好,計劃妥當,讓大學也過的精彩,不要讓我們的大學時光荒廢掉,加油!
6. C語言的輸入及輸出的教學視頻或文字說明,好用的編寫C語言的 程序(最好是中文的,英語的也可)
推薦一個網站,裡面有很多的C語言的基礎教程 「C語言也能幹大事」就是一套比較好的視屏教程,建議有空去看看,至於平台裡面會有一個免費的平台叫「C-FREE」很好用,有漢化包,下載安裝就可以用了,VC++6.0也可以用,比較小,功能很強對C語言全面支持,而且是有中文的,也不錯,很多等級考試用的都是這個平台,如果是學生的話,建議使用這個平台
7. [C語言][表達式計算][逗號表達式]表達式計算順序的疑問
以匯編視圖查看實際的操作:
1、ptr [ebp-4]置為0,ebp-4得到的是變數a的內存地址,也就是a賦值為0了。
2、寄存器EAX置為ptr [ebp-4],也就是a的值放入寄存器。
3、add eax,1,就是EAX寄存的值+1。
也就是說intb = a + (a=0,1);這條語句被理解成a=0;int b=a+1;。也不知道不同編譯環境下是否還有所不同?我一開始跟樓主想得也一樣,b的值應該是2。具體的原因我也很想知道,期待高手詳解。不過b = a + (a=0,1);這種代碼只能用來研究,不提倡實際編寫,編程不是做密碼,容易歧義的東西會耽誤事的。
8. 用C語言編程《通訊管理系統》
建一個順序表,然後在以上函數中調用順序表的各個函數
9. C語言中 system的各種參數
註:這是CSDN上的RookieStar回答的
我以這個為測試為例:system( "abcde ");
顯示如下:
'abcde ' 不是內部或外部命令,也不是可運行的程序
或批處理文件。
Press any key to continue
這個很能說明問題:在windows操作系統下,system()函數真正調用的是命令解釋器文件cmd.exe,這個我想你應該知道吧,通過解釋器將傳入的字元串轉成相應的內部/外部命令或可運行程序以及批處理文件,就能解決你關於pause(內部指令)、clrscr(外部命令)的問題了。不過這里還有個小問題,我的中文XP下cmd似乎也是英文版本的,所以pause顯示英文,而console程序顯示的是中文,我個人理解是console程序與操作系統間有密切關系(可能存在語言的轉譯或內部調用一個中文的cmd),所以console程序結果與cmd結果在內容上有語言的區別。至於內部指令的實現問題,還是讓m$好好教你吧! :)
順便附上msdn中關於system函數的說明,供你參考:
system, _wsystem
Execute a command.
int system( const char *command );
int _wsystem( const wchar_t *command );
Routine Required Header Compatibility
system <process.h> or <stdlib.h> ANSI, Win 95, Win NT
_wsystem <process.h> or <stdlib.h> or <wchar.h> Win NT
For additional compatibility information, see Compatibility in the Introction.
Libraries
LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version
Return Value
If command is NULL and the command interpreter is found, the function returns a nonzero value. If the command interpreter is not found, it returns 0 and sets errno to ENOENT. If command is not NULL, system returns the value that is returned by the command interpreter. It returns the value 0 only if the command interpreter returns the value 0. A return value of – 1 indicates an error, and errno is set to one of the following values:
E2BIG
Argument list (which is system-dependent) is too big.
ENOENT
Command interpreter cannot be found.
ENOEXEC
Command-interpreter file has invalid format and is not executable.
ENOMEM
Not enough memory is available to execute command; or available memory has been corrupted; or invalid block exists, indicating that process making call was not allocated properly.
Parameter
command
Command to be executed
Remarks
The system function passes command to the command interpreter, which executes the string as an operating-system command. system refers to the COMSPEC and PATH environment variables that locate the command-interpreter file (the file named CMD.EXE in Windows NT). If command is NULL, the function simply checks to see whether the command interpreter exists.
You must explicitly flush (using fflush or _flushall) or close any stream before calling system.
_wsystem is a wide-character version of system; the command argument to _wsystem is a wide-character string. These functions behave identically otherwise.
Generic-Text Routine Mappings
TCHAR.H Routine _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined
_tsystem system system _wsystem
Example
/* SYSTEM.C: This program uses
* system to TYPE its source file.
*/
#include <process.h>
void main( void )
{
system( "type system.c " );
}
Output
/* SYSTEM.C: This program uses
* system to TYPE its source file.
*/
#include <process.h>
void main( void )
{
system( "type system.c " );
}
10. C語言計算的問題
3.0/2以及3.0/2.0結果都是雙精度浮點數,佔8個位元組。你提供的格式符,%d %f代表的類型都是4位元組。
反匯編代碼如下:
.file "1.c"
.def ___main; .scl 2; .type 32; .endef
.section .rdata,"dr"
LC1:
.ascii "%d %d\0"
LC2:
.ascii "\12 %d %f\0"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
LFB13:
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
andl $-16, %esp
subl $32, %esp
call ___main
fldl LC0
fstpl 12(%esp)
fldl LC0
fstpl 4(%esp)
movl $LC1, (%esp)
call _printf
fldl LC0
fstpl 12(%esp)
fldl LC0
fstpl 4(%esp)
movl $LC2, (%esp)
call _printf
movl $0, %eax
leave
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
.cfi_endproc
LFE13:
.section .rdata,"dr"
.align 8
LC0:
.long 0
.long 1073217536
.ident "GCC: (i686-posix-dwarf-rev1, Built by MinGW-W64 project) 4.9.2"
.def _printf; .scl 2; .type 32; .endef
那個LC0就是1.5在內存中的存儲形式,它的前4位元組剛好是0,所以你看到的只有0