A. 誰來幫忙做下華師c語言作業!幫忙做成程序!以下是作業要求
這個很基礎啊,我把關鍵部分寫下,完整程序自己來寫吧
(1)大寫轉化小寫 char szUpWord;//保存大寫字元
char szLowWord;//保存小寫
szUpWord = szLowWord + 『A』 - 『a』;//這里是用ASCⅡ 碼的值來計算的
(2)循環是最基本的 while循環界限值每次加1在循環裡面做;for在循環條件裡面寫;給你for的
for(i = 1;i<=100;i++)
sum+=i; //sum求和值,初始值0
(3)字元串數組的名字就是一個指針 char szText[100]; //szText 就是這個字元串的初始地址指針
scanf("%s",szText);//輸入字元串
倒序輸入去看下str*類型的庫函數吧,主要就是字元串的長度
B. c語言程序設計作業!!急!!
第一題:
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main()
{
int i,j, a,b, res, sum=0;
char ch;
printf("Now ready to answer!\nEvery question you have 3 chances to answer, first chance you answer right you can got 10, second got 7, third got 5. Otherwise can not got score!\n");
for(i=0; i<10; i++)
{
printf("%dth question:", i+1);
srand(time(NULL));
a = rand()%50;
b = rand()%(a>25?(50-a):a);
ch = rand()%2;
if(ch) ch='+';
else ch='-';
printf("%d %c %d = ", a, ch, b);
for(j=0; j<3; j++)
{
scanf("%d", &res);
if(ch=='+')
if(res==a+b){
printf("right!\n");
switch(j){
case 0: sum+=10;break;
case 1: sum+=7; break;
case 2: sum+=5; break;
}
break;
}
else{
printf("wrong!\n");
if(j!=2)printf("try again:");
}
else
if(res==a-b){
printf("right!\n");
switch(j){
case 0: sum+=10;break;
case 1: sum+=7; break;
case 2: sum+=5; break;
}
break;
}
else{
printf("wrong!\n");
if(j!=2)printf("try again:");
}
}
}
printf("your score is : %d\n", sum);
return 0;
}
C. C語言程序設計大作業🙏🙏🙏
大作業很重要,你這個最好請我來寫。
D. C語言程序設計作業 求解答
D
B
C
D
此題有歧意,本意可能讓選C,但在標識符中間不得有注釋;D又不對,起碼得有個空main
C
D
A
一天了沒人做,我來做做……
E. C語言程序設計的作業
#include<stdio.h>
intmain()
{
intf;
floatl,s;
while(1)
{
printf("
輸入限速值及所測車速:");
scanf("%f%f",&l,&s);
if(s-l<0)
printf("未超速不處罰記%d分
",f=0);
elseif((s-l)/l<0.2)
printf("超速未到20%%記%d分
",f=3);
elseif((s-l)/l>=0.2&&(s-l)/l<0.5)
printf("超速20%%未到50%%記%d分
",f=6);
elseif((s-l)/l>=0.5)
printf("超速50%%及以上記%d分
",f=12);
printf("駕駛證剩餘分數:%d
",12-f);
}
return0;
}
#include<stdio.h>
intgeti(charc);//獲取字元對應下標
intmain()
{
intia,ib;
chara,b;
printf("猜拳游戲:'V'表示剪刀,'S'表示石頭,'P'表示布
");
while(1)
{
printf("請輸入玩家a的手勢:");
scanf("%c",&a);
getchar();
printf("請輸入玩家b的手勢:");
scanf("%c",&b);
getchar();
ia=geti(a);
ib=geti(b);
if(ia==-1||ib==-1)
{
printf("輸入不符合規則,請重新輸入!
");
continue;
}
if(ia-ib==1||ia-ib==-2)
printf("玩家a勝
");
elseif(ia-ib==-1||ia-ib==2)
printf("玩家b勝
");
else
printf("平局
");
}
return0;
}
intgeti(charc)//獲取字元對應下標
{
charg[3]={'V','S','P'};//數組元素依次克前一個元素及被後一個元素克制
inti=0;
for(i=0;i<3;i++)
if(g[i]==c)
returni;
return-1;
}
F. C語言程序設計作業求解答
9.d;
10.c;
11.d;
12.c;
13.b;
14.d;
15.a.
G. c語言程序設計作業
//數據文件放在D盤下,名稱為1.txt
//格式為:學號姓名C語言成績數學成績物理成績
//例如:
//001趙日天958892
//002劉斬仙596273
#include<stdio.h>
#include<stdlib.h>
typedefstruct
{
charnum[8];
charname[10];
intcgrade;
intmgrade;
intphysics;
floatave;
}STUDENT;
intmain()
{
STUDENTs[50];
intcount=0;
FILE*fp;
charbuf[100];
if((fp=fopen("d:\1.txt","r"))==NULL)
{
printf("Openfilefalied!");
return-1;
}
while(!feof(fp))
{
fgets(buf,100,fp);
sscanf(buf,"%s%s%d%d%d",s[count].num,s[count].name,&s[count].cgrade,&s[count].mgrade,&s[count].physics);
s[count].ave=(s[count].cgrade+s[count].mgrade+s[count].physics)/3.0;
count++;
}
fclose(fp);
printf("共有%d人 ",count);
inti,j;
for(i=0;i<count;i++)
{
printf("%-5s%-6s%-3d%-3d%-3d%-5.2f ",s[i].num,s[i].name,s[i].cgrade,s[i].mgrade,s[i].physics,s[i].ave);
}
intmax[3]={0,0,0},min[3]={100,100,100},sum[3]={0,0,0};
floatave[3]={0.0};
intgood[3]={0,0,0},pass[3]={0,0,0},unpass[3]={0,0,0};
for(i=0;i<count;i++)
{
sum[0]+=s[i].cgrade;
sum[1]+=s[i].mgrade;
sum[2]+=s[i].physics;
if(max[0]<s[i].cgrade) max[0]=s[i].cgrade;
if(max[1]<s[i].mgrade) max[1]=s[i].mgrade;
if(max[2]<s[i].physics)max[2]=s[i].physics;
if(min[0]>s[i].cgrade) min[0]=s[i].cgrade;
if(min[1]>s[i].mgrade) min[1]=s[i].mgrade;
if(min[2]>s[i].physics)min[2]=s[i].physics;
if(s[i].cgrade>=90) good[0]++;
elseif(s[i].cgrade>=60)pass[0]++;
else unpass[0]++;
if(s[i].mgrade>=90)good[1]++;
elseif(s[i].mgrade>=60)pass[1]++;
else unpass[1]++;
if(s[i].physics>=90)good[2]++;
elseif(s[i].mgrade>=60)pass[2]++;
else unpass[2]++;
}
ave[0]=(float)sum[0]/(float)count;
ave[1]=(float)sum[1]/(float)count;
ave[2]=(float)sum[2]/(float)count;
printf(" C語言成績: ");
printf("最高分:%d最低分:%d平均分:%.2f",max[0],min[0],ave[0]);
printf(" 優秀:%d及格:%d不及格:%d",good[0],pass[0],unpass[0]);
printf(" 數學成績: ");
printf("最高分:%d最低分:%d平均分:%.2f",max[1],min[1],ave[1]);
printf(" 優秀:%d及格:%d不及格:%d",good[1],pass[1],unpass[1]);
printf(" 物理成績: ");
printf("最高分:%d最低分:%d平均分:%.2f",max[2],min[2],ave[2]);
printf(" 優秀:%d及格:%d不及格:%d",good[2],pass[2],unpass[2]);
int*all_score;
all_score=(int*)malloc(sizeof(int)*count);
for(i=0;i<count;i++)
{
all_score[i]=s[i].cgrade+s[i].mgrade+s[i].physics;
}
//排序
intt;
for(i=0;i<count-1;i++)
{
for(j=0;j<count-1-i;j++)
{
if(all_score[i]<all_score[i+1])
{
i=all_score[i];
all_score[i]=all_score[i+1];
all_score[i+1]=i;
}
}
}
printf(" 總成績最高到低為: ");
for(i=0;i<count;i++)
{
printf("%d",all_score[i]);
}
return0;
}
H. C語言程序設計作業
#include<stdio.h>
intgeti(charc);//獲取字元對應下標
intmain()
{
intia,ib;
chara,b;
printf("猜拳游戲:'V'表示剪刀,'S'表示石頭,'P'表示布
");
while(1)
{
printf("請輸入玩家a的手勢:");
scanf("%c",&a);
getchar();
printf("請輸入玩家b的手勢:");
scanf("%c",&b);
getchar();
ia=geti(a);
ib=geti(b);
if(ia==-1||ib==-1)
{
printf("輸入不符合規則,請重新輸入!
");
continue;
}
if(ia-ib==1||ia-ib==-2)
printf("玩家a勝
");
elseif(ia-ib==-1||ia-ib==2)
printf("玩家b勝
");
else
printf("平局
");
}
return0;
}
intgeti(charc)//獲取字元對應下標
{
charg[3]={'V','S','P'};//數組元素依次克前一個元素及被後一個元素克制
inti=0;
for(i=0;i<3;i++)
if(g[i]==c)
returni;
return-1;
}
I. 12秋華師《C語言程序設計》作業如何製作源文件
新建txt文件,把程序放入,然後把後綴.txt改為.c,就可以了,每個程序單獨放入。或者用編譯軟體(如VC)也可以產生。
J. 幫忙做一道C語言程序設計作業
可以參考
#include "stdio.h" /*I/O函數*/
#include "stdlib.h" /*其它說明*/
#include "string.h" /*字元串函數*/
#include "conio.h" /*屏幕操作函數*/
#include "mem.h" /*內存操作函數*/
#include "ctype.h" /*字元操作函數*/
#include "alloc.h" /*動態地址分配函數*/
struct score
{
int mingci;
char xuehao[8];
char mingzi[20];
float score[6];
}data,info[1000];
int i,j,k=0;
char temp[20],ch;
FILE *fp,*fp1;
void shuru()
{
if((fp=fopen("s_score.txt","ab+"))==NULL)
{
printf("cannot open this file.\n");
getch();exit(0);
}
for(i=0;i<=1000;i++)
{
printf("\nPlease shuru xuehao:");
gets(data.xuehao);
printf("Please shuru mingzi:");
gets(data.mingzi);
printf("Please shuru yuwen score:");
gets(temp);data.score[0]=atof(temp);
printf("Please shuru shuxue score:");
gets(temp);data.score[1]=atof(temp);
printf("Please input yingyu score:");
gets(temp);data.score[2]=atof(temp);
printf("Please shuru wuli score:");
gets(temp);data.score[3]=atof(temp);
printf("Please shur huaxue score:");
gets(temp);data.score[4]=atof(temp);
data.score[5]=data.score[0]+data.score[1]+data.score[2]+data.score[3]+data.score[4];
fwrite(&data,sizeof(data),1,fp);
printf("another?y/n");
ch=getch();
if(ch=='n'||ch=='N')
break;
} fclose(fp);
}
void xianshi()
{
float s;int n;
if((fp=fopen("s_score.txt","rb+"))==NULL)
{
printf("Cannot reading this file.\n");
exit(0);
}
for(i=0;i<=1000;i++)
{
if((fread(&info[i],sizeof(info[i]),1,fp))!=1)
break;
}
printf("\nxuehao mingzi yuwen shuxue yingyu wuli huauxue zhongfen\n");
for(j=0,k=1;j<i;j++,k++)
{
info[j].mingci=k;
printf("%6s %8s %3.1f %3.1f %3.1f %3.1f %3.1f %3.1f\n",info[j].xuehao,info[j].mingzi,info[j].score[0],info[j].score[1],info[j].score[2],info[j].score[3],info[j].score[4],
info[j].score[5]);
}
getch();
fclose(fp);
}
void xiugai()
{
if((fp=fopen("s_score.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL)
{
printf("Cannot open this file.\n");
exit(0);
}
printf("\nPLease shuru xiugai xuehao:");
scanf("%d",&i); getchar();
while((fread(&data,sizeof(data),1,fp))==1)
{
j=atoi(data.xuehao);
if(j==i)
{
printf("xuehao:%s\nmingzi:%s\n",data.xuehao,data.mingzi);
printf("Please shuru mingzi:");
gets(data.mingzi);
printf("Please shuru yuwen score:");
gets(temp);data.score[0]=atof(temp);
printf("Please shuru shuxue score:");
gets(temp);data.score[1]=atof(temp);
printf("Please input yingyu score:");
gets(temp);data.score[2]=atof(temp);
printf("Please input wuli score:");
gets(temp);data.score[3]=atof(temp);
printf("Please input huaxue score:");
gets(temp);data.score[4]=atof(temp);
data.score[5]=data.score[0]+data.score[1]+data.score[2]+data.score[3]+data.score[4];
} fwrite(&data,sizeof(data),1,fp1);
}
fseek(fp,0L,0);
fseek(fp1,0L,0);
while((fread(&data,sizeof(data),1,fp1))==1)
{
fwrite(&data,sizeof(data),1,fp);
}
fclose(fp);
fclose(fp1);
}
void chazhao()
{
if((fp=fopen("s_score.txt","rb"))==NULL)
{
printf("\nCannot open this file.\n");
exit(0);
}
printf("\nPLease shuru xuehao chakan:");
scanf("%d",&i);
while(fread(&data,sizeof(data),1,fp)==1)
{
j=atoi(data.xuehao);
if(i==j)
{
printf("xuehao:%s mingzi:%s\nyuwen:%f\n shuxue:%f\n yingyu:%f\n wuli:%f\n huaxue:%f\n ",data.xuehao,data.mingzi,data.score[0],data.score[1],data.score[2],data.score[3],data.score[4],data.score[5]);
}getch();
}
}
void shanchu()
{
if((fp=fopen("s_score.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL)
{
printf("\nopen score.txt was failed!");
getch();
exit(0);
}
printf("\nPlease input ID which you want to del:");
scanf("%d",&i);getchar();
while((fread(&data,sizeof(data),1,fp))==1)
{
j=atoi(data.xuehao);
if(j==i)
{
printf("Anykey will delet it.\n");
getch();
continue;
}
fwrite(&data,sizeof(data),1,fp1);
}
fclose(fp);
fclose(fp1);
remove("s_score.txt");
rename("temp.txt","s_score.txt");
printf("Data delet was succesful!\n");
printf("Anykey will return to main.");
getch();
}
main()
{
while(1)
{
clrscr(); /*清屏幕*/
gotoxy(1,1); /*移動游標*/
textcolor(YELLOW); /*設置文本顯示顏色為黃色*/
textbackground(BLUE); /*設置背景顏色為藍色*/
window(1,1,99,99); /* 製作顯示菜單的窗口,大小根據菜單條數設計*/
clrscr();
printf("*************welcome to use student manage******************\n");
printf("*************************menu********************************\n");
printf("* ========================================================= * \n");
printf("* 1>shuru 2>xiugai * \n");
printf("* 3>shanchu 4>chazhao * \n");
printf("* 5>xianshi 6>exit * \n");
printf("* * \n");
printf("* --------------------------------------------------------- * \n");
printf(" Please input which you want(1-6):");
ch=getch();
switch(ch)
{
case '1':shuru();break;
case '2':xiugai(); break;
case '3':shanchu(); break;
case '4':chazhao(); break;
case '5':xianshi(); break;
case '6':exit(0);
default: continue;
}
}
}