c语言程序设计怎么做

c语言程序设计怎么做,第1张

//例题1

#include <stdioh>

#include "stringh"

int main()

{

double twages=000;

double hours=000;

double swages=000;

printf( "请输入劳动时间\n" );

scanf("%lf",&hours);

printf( "请输入每小时工资\n");

scanf("%lf",&swages);

//计算应发工资

twages=swageshours09;

printf("应发工资[%2lf]\n",twages);

return 0;

}

//例题2

#include <stdioh>

#include "stringh"

int main()

{

int num1=1500;

int num2=350;

int shang=0;

int yushu=0;

shang=num1/num2;

yushu=num1%num2;

printf("商[%d]余数[%d]\n",shang,yushu);

return 0;

}

//例题3

#include <stdioh>

#include "stringh"

int main()

{

double temperature1=000;

double temperature2=000;

printf("请输出华氏温度F\n");

scanf("%lf", &temperature1);

temperature2=(double)5/9(temperature1-32);

printf("摄氏温度[%2lfC]\n",temperature2);

return 0;

}

//例题4

#include <stdioh>

#include "stringh"

int main()

{

double totamt=000;

double payamt=000;

double chgamt=000;

double appleweight=000;

double bananaweight=000;

double orangeweight=000;

double appleprice=350;

double bananaprice=260;

double orangeprice=180;

printf( "请输入苹果重量\n" );

scanf("%lf",&appleweight);

printf( "请输入香蕉重量\n" );

scanf("%lf",&bananaweight);

printf( "请输入橘子重量\n" );

scanf("%lf",&orangeweight);

totamt=appleweightappleprice+bananaweightbananaprice+orangeweightorangeprice;

printf("应付金额[%2lf]\n", totamt);

do{

printf("请输入客户支付金额\n");

scanf("%lf",&payamt);

}while( payamt<totamt );   //支付金额小于总金额时,重复输入动作

chgamt=payamt-totamt;

printf("顾客找零[%2lf]\n", chgamt );

return 0;

}

#include<stdioh>

void main()

{

int iA,iB,iC;

while(1){//加个循环

printf("input numbers(a,b):");

scanf("%d%d",&iA,&iB);

if(iA>7&&iB>7)

break;

else

iC=iA+iB;

printf("iC=%d\n",iC);

}

}

一般是这样,在一般程序设计都是多组输入,不过是单组的话其实 if()return 0;也是可以的

《零基础学编程》(赵建领)电子书网盘下载免费在线阅读

r4y8

书名:零基础学编程

作者:赵建领

出版社:机械工业出版社

出版年份:2014-7-1

页数:504

内容简介:

单片机C51语言是目前最流行的单片机程序设计语言。本书由浅入深,循序渐进地讲解了C51语言的方方面面。本书知识点覆盖全面、结构安排紧凑、讲解详细、言简意赅、通俗易懂、实例丰富。内容包括51系列单片机开发环境和流程、程序设计基础以及编程指南,并给出了一些常用的典型案例。全书分为四篇,共21章,全面详细地讲述了单片机的程序设计基础、编程指南及应用案例。首先介绍了51系列单片机的基本结构以及单片机的开发概述,其次详细介绍了单片机程序设计的C51语言,然后结合单片机的硬件资源细致讲解了如何应用C51语言进行编程 *** 作,最后结合实际应用,重点分析了在各个领域中常用到的一些典型案例,使读者更加融会贯通地掌握C51语言,以供读者在学习和工作中进行参考。在第21章中还介绍了部分常见的面试题及解答,方便读者做好入职前的准备工作。

#include "graphicsh"

#define SIZE 100

#include <conioh>

#include<stdioh>

int N;

struct student

{

int No ;

int age;

char name[10];

char sex;

int computerscore;

int Englishscore;

int Mathscore;

int Sum[10];

int aver[10];

char Dengji[10];

}stud[SIZE];

FILEfp;

int i;

int j;

int m;

int n;

int o;

void input()

{

i=1;

printf("please input student data\n");

while(i<=N)

{

printf("No :");

scanf("%d",&stud[i]No );

printf("name:");

scanf("%s",stud[i]name);

printf("age");

scanf("%d",&stud[i]age);

printf("sex");

getchar();

scanf("%c",&stud[i]sex);

printf("computerscore:");

scanf("%d",&stud[i]computerscore);

printf("Englishscore:");

scanf("%d",&stud[i]Englishscore);

printf("Mathscore:");

scanf("%d",&stud[i]Mathscore);

i++;

}

}

chuli(struct student stud[])

{

int k,m;

struct student t;

int Sum[SIZE],aver[SIZE];

for(i=1;i<=N;i++)

Sum[i]=stud[i]computerscore+stud[i]Englishscore+stud[i]Mathscore;

for(i=1;i<=N;i++)

aver[i]=Sum[i]/3;

for(i=1;i<=N;i++)

{

k=i;

{

for(j=i+1;j<=N;j++)

if(Sum[i]<Sum[j])

k=j;

if(k!=i)

{

t=stud[i];stud[i]=stud[k];stud[k]=t;

m=Sum[i];Sum[i]=Sum[k];Sum[k]=m;

n=aver[i];aver[i]=aver[k];aver[k]=n;

}

}

}

for(i=1;i<=N;i++)

{

if(aver[i]>=90)

{printf("%d\t%s\t%d\t%c\t%d\t%d\t%d\t%d\t%d\tA\n",stud[i]No ,stud[i]name,stud[i]age,stud[i]sex,stud[i]computerscore,stud[i]Englishscore,stud[i]Mathscore,Sum[i],aver[i]);

printf("\t\t\t\t\twelldone!please go on!\n");

}

else if(aver[i]>=80)

printf("%d\t%s\t%d\t%c\t%d\t%d\t%d\t%d\t%d\tB\n",stud[i]No ,stud[i]name,stud[i]age,stud[i]sex,stud[i]computerscore,stud[i]Englishscore,stud[i]Mathscore,Sum[i],aver[i]);

else if(aver[i]>=70)

printf("%d\t%s\t%d\t%c\t%d\t%d\t%d\t%d\t%d\tC\n",stud[i]No ,stud[i]name,stud[i]age,stud[i]sex,stud[i]computerscore,stud[i]Englishscore,stud[i]Mathscore,Sum[i],aver[i]);

else if(aver[i]>=60)

printf("%d\t%s\t%d\t%c\t%d\t%d\t%d\t%d\t%d\tD\n",stud[i]No ,stud[i]name,stud[i]age,stud[i]sex,stud[i]computerscore,stud[i]Englishscore,stud[i]Mathscore,Sum[i],aver[i]);

else

{

printf("%d\t%s\t%d\t%c\t%d\t%d\t%d\t%d\t%d\tE\n",stud[i]No ,stud[i]name,stud[i]age,stud[i]sex,stud[i]computerscore,stud[i]Englishscore,stud[i]Mathscore,Sum[i],aver[i]);

printf("\t\t\t\t\tYou should work hard!\n");

}

}

}

Maxcomputerscore(struct student stud[])

{

int i=0,Max;

Max=stud[i]computerscore;

m=stud[i]No ;

for(i=1;i<N;i++)

if(Max<stud[i]computerscore)

{

Max=stud[i]computerscore;

m=stud[i]No ;

}

printf("Maxcomputerscore:");

printf("Max=%d,m=%d\n",Max,m);

}

Maxenglishscore(struct student stud[])

{

int i,Max;

i=0;

Max=stud[i]Englishscore;

m=stud[i]No ;

for(i=1;i<N;i++)

if(Max<stud[i]Englishscore)

{

Max=stud[i]Englishscore;

m=stud[i]No ;

}

printf("Max Englishscore:");

printf("Max=%d,m=%d\n",Max,m);

}

MaxMathscore(struct student stud[])

{

int i=0;

int m;

int Max;

Max=stud[i]Mathscore;

m=stud[i]No ;

for(i=1;i<N;i++)

if(Max<stud[i] Mathscore)

{

Max=stud[i]Mathscore;

m=stud[i]No ;

}

printf("MaxMathscore:");

printf("Max=%d,m=%d\n",Max,m);

}

main()

{

char ch;

int i,k,driver=DETECT,mode;

initgraph(&driver,&mode,"c:\\tc");

system("cls");

printf("\t\t\n");

setbkcolor(BLUE);cleardevice();

setfillstyle(1,2);

setcolor(YELLOW);

rectangle(100,100,540,380);

floodfill(50,50,14);

setcolor(12);

settextstyle(1,0,8);

outtextxy(130,150,"welcome!");

printf("\t\t\t\t\t\n");

printf("\t\t please input the number of students!\t\t\t\t");

scanf("%d",&N);

system("cls");

printf("\t\t---------------------------------------\n");

printf("\t\tT:input the student data \n");

printf("\t\t\C:have a look at the data \n");

printf("\t\tL:get every subject the highest score \n");

printf("\t\tJ:stored information \n");

printf("\t\tX:quit the program \n");

printf("\t\t---------------------------------------\n");

printf("please input your choise:");

while((ch=getchar())!='w')

{

switch(ch)

{

case'T':input();

break;

case'C':

chuli(stud);

break;

case'L':

Maxcomputerscore(stud);

Maxenglishscore(stud);

MaxMathscore(stud);

break;

case'X':exit(o);

case'J':

fp=fopen("studenttxt","w+");/创建一个sutdentxt文本文件/

if(!fp)

{

printf("cannot open the file");

return;

}/在文件头写入包含的学生信息/

for(i=0;i<N;i++)

fprintf(fp,"%d\t%s\t%d\t%c\t%d\t%d\t%d\t%d\t%d\t\n",stud[i]No ,stud[i]name,stud[i]age,stud[i]sex,stud[i]computerscore,stud[i]Englishscore,stud[i]Mathscore);

fclose(fp);/写完后关闭文件/

break;

default: printf("\nplease input the right word:\nTCLJX\n");

}

printf("\n--------------over------------------------------\n");

}

}

以上就是关于c语言程序设计怎么做全部的内容,包括:c语言程序设计怎么做、c语言程序设计、《零基础学编程零基础学单片机C语言程序设计》epub下载在线阅读全文,求百度网盘云资源等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/9969960.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-03
下一篇2023-05-03

发表评论

登录后才能评论

评论列表(0条)

    保存