编译需要编译器,如gcc,vc,c-free等。
运行的话,只要装了 *** 作系统的电脑都行
(同一个程序可能不能在不同系统或电脑环境下运行)
(如针对64位 *** 作系统写的程序不能在32位 *** 作系统下运行)
#include<stdioh>
#include<conioh>
#define N 100
typedef struct stu
{
char num[10];
char name[12];
int age;
float score[2];
float total;
float average;
}STU;
void ptint(STU student[],int n)
{
int i;
puts("All students information:\n");
puts("name num age total average\n");
for(i=0;i<n;i++)
{
printf("%s %s %4d %02f %02f\n",student[i]name,student[i]num,
student[i]age,student[i]total,student[i]average);
}
}
void sort(STU student[],int n)
{
int i,j,imax,k;
STU s;
for(i=0;i<n-1;i++)
{
imax=i;
for(j=i+1;j<n;j++)
{
if(student[imax]total<student[j]total) imax=j;
if(i!=imax)
{
for(k=0;k<12;k++)
sname[k]=student[i]name[k];
for(k=0;k<10;k++)
snum[k]=student[i]num[k];
sage=student[i]age;
sscore[0]=student[i]score[0],sscore[1]=student[i]score[1];
stotal=student[i]total,saverage=student[i]average;
for(k=0;k<12;k++)
student[i]name[k]=student[imax]name[k];
for(k=0;k<10;k++)
student[i]num[k]=student[imax]num[k];
student[i]age=student[imax]age,student[i]score[0]=student[imax]score[0];
student[i]score[1]=student[imax]score[1];
student[i]total=student[imax]total,student[i]average=student[imax]average;
for(k=0;k<12;k++)
student[imax]name[k]=sname[k];
for(k=0;k<10;k++)
student[imax]num[k]=snum[k];
student[imax]age=sage;
student[imax]score[0]=sscore[0],student[imax]score[1]=sscore[1];
student[imax]total=stotal,student[imax]average=saverage;}
}
}
printf("The total score zuigao student:\n");
puts("name num age total average\n");
printf("%-6s %s %4d %02f %02f\n",student[0]name,student[0]num,
student[0]age,student[0]total,student[0]average);
for(i=1;i<n;i++)
if(student[i]total==student[0]total)
{
printf("%-6s %s %4d %02f %02f\n",student[i]name,student[i]num,
student[i]age,student[i]total,student[i]average);
}
ptint(student,n);
}
void count(STU student[],int n)
{
int i;
for(i=0;i<n;i++)
{
student[i]total=student[i]score[0]+student[i]score[1];
student[i]average=(float)student[i]total/2;
printf("The student%d's total score is %02f ",i,student[i]total);
printf("average score is %02f\n",student[i]average);
}
sort(student,n);
}
int main()
{
int i,j,n;
STU stud[N];
printf("Please input students numbers:\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
puts("Please input students'name:");
scanf("%s",&stud[i]name);
puts("Please input students'num:");
scanf("%s",&stud[i]num);
puts("Please input students'age:");
scanf("%d",&stud[i]age);
puts("Please input students'two score:");
for(j=0;j<2;j++)
scanf("%f",&stud[i]score[j]);
}
count(stud,n);
}
VC60默认编译器选项是这样的,为了优化代码的执行效率,在同一表达式连续累加的时候保持原值静态不变。你可以根据需要选择不同的编译选项。
不单是VC60,包括GNU DEV C++、G++等任何一种现代编译器,都在优化代码、优化地址空间上大做文章。你如果感兴趣,可以学习ANSI C为基础标准,每种编译器对ANSI C的实现是不一样的,即使是GNU C++,那么标准化的程序,也只实现ANSI C的97%语法标准。
对于上面的问题,有很多种解决方法:
1、不要尝试用一些很含混晦涩、不易阅读和书写的表达式,尽量以ANSI C语法为标准写;
2、如果要使用编译器特殊优化功能,请学会使用预定义和预编译选项,比如内存对齐、库函数调用:
#ifdef WIN32
#pragma pack(1)
#include <windowsh>
#else
#include <pthreadh>
#endif
这样上面的代码就可以在WINDOWS和LINUX之间兼容编译畅通无阻。
这些内容在现代C语言都很常见的,真的没什么大惊小怪。要怪就怪老师本身对现代编译器内容很少介绍,而且也太图省事,只把垃圾一样的TURBO C捧为经典。要知道TC是20年前的DOS产品,把所有问题归咎于古董而过于依赖是不对的。
虽然懒惰的老师们都应该被拖出去打屁股,但是聪明的学生应该懂得考试的时候怎么办,挣钱的时候又该怎么办。
楼主把显卡驱动从装一下!试试!要是纯平的话把显示器的分辨率调到1024768,刷新率调到85或75hz(赫兹),要是19寸液晶显示器的话分辨率调到1440900,刷新率调到60hz(赫兹)
或者检查一下机箱是否有灰尘!清理一下!
/什么年代了,你还是要turbo c,早就过时了,强烈建议用 vc 60,学C语言,c++最好的编译器,没有之一,vs是开发人员用的。 下面是C语言在VC 下的动态心形图/
#include<stdioh>
#include<mathh>
#include<windowsh>
HWND GetConsoleHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles
HWND hwndFound; // This is what is returned to the caller
char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated
char pszOldWindowTitle[MY_BUFSIZE]; // Contains original
GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);//获取控制台标题存入pszOldWindowTitle中
//设置控制台的标题为 时间数 进程ID
wsprintf(pszNewWindowTitle,"%d/%d",//把获取的数目,和当前进程ID输出到缓冲区pszNewwindowtitle中
GetTickCount(),//用于获取 *** 作系统启动后的毫秒数
GetCurrentProcessId());//获取当前进程ID
SetConsoleTitle(pszNewWindowTitle);//更改控制台的标题为新内容
Sleep(40);
hwndFound=FindWindow(NULL, pszNewWindowTitle);//获取控制台的HWND号
SetConsoleTitle(pszOldWindowTitle);//更改控制台的标题为原始内容
return(hwndFound);//返回句柄
}
void drawXY()//绘制X和Y轴
{
HWND hWnd=GetConsoleHwnd();//获取控制台窗口句柄,用于设置画笔颜色
HDC hDC=GetDC(hWnd);
COORD dwSize;//记录窗体大小,用于设定坐标轴远点
HPEN hNewPen=CreatePen(PS_SOLID,1,RGB(255,0,0));//创建画笔对象
HPEN hOldPen=(HPEN)SelectObject(hDC,hNewPen);//选取画笔对象进行绘图
CONSOLE_SCREEN_BUFFER_INFO bInfo; // 窗口信息
HANDLE Hout=GetStdHandle(STD_OUTPUT_HANDLE);//获取控制台句柄
GetConsoleScreenBufferInfo(Hout, &bInfo );//获取控制台信息
dwSize=bInfodwMaximumWindowSize ;//获取窗口大小,此时获得的是字符模式下
//从字符到图像放大坐标轴8倍
dwSizeX =8;
dwSizeY=8;
SetBkMode(hDC, TRANSPARENT);SetTextColor(hDC,255255);
//绘制X轴各个特殊坐标
TextOut(hDC,dwSizeX-15,dwSizeY/2-15,"X",1);
//Arc(hDC,100,100,300,300,350,500,350,500);//画圆 其中hDC表示画图句柄,100,100,300,300表示所使用的矩形区域,350,500表示画弧线的起点,350,500表明画弧线的终点 ;
//绘制Y轴各个特殊坐标
TextOut(hDC,dwSizeX/2,0,"Y",1);
MoveToEx(hDC,0,dwSizeY /2,NULL);
LineTo(hDC,dwSizeX,dwSizeY/2);
MoveToEx(hDC,dwSizeX/2,0,NULL);
LineTo(hDC,dwSizeX/2,dwSizeY);
ReleaseDC(hWnd,hDC);
}
void draw(double p)
{
int i;
double x,y;
HWND hWnd=GetConsoleHwnd();//获取控制台窗口句柄,用于设置画笔颜色
HDC hDC=GetDC(hWnd);
COORD dwSize;//记录窗体大小,用于设定坐标轴远点
HPEN hNewPen=CreatePen(PS_SOLID,1,RGB(255,0,0));//创建画笔对象
HPEN hOldPen=(HPEN)SelectObject(hDC,hNewPen);//选取画笔对象进行绘图
CONSOLE_SCREEN_BUFFER_INFO bInfo; // 窗口信息
HANDLE Hout=GetStdHandle(STD_OUTPUT_HANDLE);//获取控制台句柄
GetConsoleScreenBufferInfo(Hout, &bInfo );//获取控制台信息
dwSize=bInfodwMaximumWindowSize ;//获取窗口大小,此时获得的是字符模式下
//从字符到图像放大坐标轴8倍
dwSizeX =8;
dwSizeY=8;
//MoveToEx(hDC,0,dwSizeY/2,NULL);
for(i=-180;i<=180;i++)
{
x=16pow(sin(i31415926/180),30)p;
y=(13cos(i31415926/180)-5cos(2i31415926/180)-2cos(3i31415926/180)-cos(4i31415926/180))p;
x=(x+16)dwSizeX/32/2+dwSizeX/4;
y=-y/16dwSizeY/23+dwSizeY/2;
x=x;
y=y;
MoveToEx(hDC,x,y,NULL);
LineTo(hDC,x+1,y+1);
}
}
int main()
{
double p;
//drawXY();
for(p=06;p<=1;p=p+001)
draw(p);
system("PAUSE");
}
VC和TC的头文件肯定不一样,不同公司出的啊,没有标准。
嵌入式编程用同文件当然也要提供硬件的公司提供,软件和硬件是配套的。
嵌入式使用的IDE无所谓,如果系统有那就使用系统提供的,如果没有可以选自己喜欢的,这和编译就没关系了。
以上就是关于C语言编译运行需要什么环境 TC吗全部的内容,包括:C语言编译运行需要什么环境 TC吗、急求一道C语言编程(TC)、C语言问题:TC与VC的不同等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)