這裡蒐索程式師資訊,查找有用的技術資料
当前位置:首页 » 编程语言 » c语言cfafb
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

c语言cfafb

发布时间: 2022-04-23 15:49:35

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