⑴ C语言设计问卷调查系统 要求用单链表做
屌丝 第三题 你就别做了 直接第四题吧~~~~~~~~~~~~~~~~~~~~~~
#include <stdio.h>
#include <stdlib.h>
struct player
{
char name[30];
int num;
char team[30];
char nationality[30];
float score[8];
float final_socre;
struct player*next;
};
void create(player * head)
{
int i=0;
struct player *player1=(struct player*)malloc(sizeof(struct player));
while(head!=NULL)
{head=head->next;
}
printf("请输入姓名\n");
scanf("%s",player1->name);
printf("请输入编号\n");
scanf("%d",&player1->num);
printf("请输入代表队\n");
scanf("%s",player1->team);
printf("请输入国籍\n");
scanf("%s",player1->nationality);
printf("请输入7位评委对其评分\n");
for(i=0;i<7;i++)
scanf("%f",&(player1->score[i]));
player1->final_socre=0;
head=player1;
player1->next=NULL;
}
float max_score(float score[])//
{
int i=0;
float max=score[0];
for(i=1;i<7;i++)
if(score[i]>max)
max=score[i];
return max;
}
float min_score(float score[])
{
int i=0;
float min=score[0];
for(i=1;i<7;i++)
if(score[i]<min)
min=score[i];
return min;
}
t n,player * head)//运动员分数的处理:删去最大值,最小值,求平均数
{int i=0;
float sum=0;
while(head!=NULL)
{
i++;
if(i==n)
{
for(i=0;i<7;i++)
sum=sum+head->score[i];
sum=sum-min_score(head->score)-max_score(head->score);
head->final_socre=sum/5.0;
break;
}
}
head=head->next;
}
void show_info(int n,player * head)
{
int i=0;
float sum=0;
while(head!=NULL)
{
i++;
if(i==n)
{
printf("姓名:%s\n",head->name);
printf("编号:%d\n",head->num);
printf("代表队:%s\n",head->team);
printf("国籍:%s\n",head->nationality);
printf("最后得分:%f\n",head->final_socre);
break;
}
}
head=head->next;
}
void main()
{
int i;
struct player *head=(struct player*)malloc(sizeof(struct player));
head->next=NULL;
printf("请为参赛的10名选手录入信息:\n");
for(i=0;i<10;i++)
create(head);
scores(1,head);
scores(10,head);
show_info(1,head);
show_info(10,head);
}
⑵ C语言程序设计课程讲什么内容
C语言程序设计课程是入门级的程序设计课程,针对没有或很少具有编程经验的在职人员。课程通过学习C语言编程的基础语法,对程序设计有一个基本的认识,为后续计算机专业课程以及面向对象程序设计课程的学习打下基础。 课程主要内容:C语言程序基本结构及相关概念、变量、函数、语句、if条件语句、switch条件语句、for循环语句、while循环语句、数组、指针、字符串、结构体。
⑶ 《C语言程序设计》课程设计
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#define BUFFERSIZE 1024
#define MAXACCOUNT 1000
typedef struct BankAccount
{
int account;
int key;
char name[32];
float balance;
}BANKACCOUNT;
BANKACCOUNT accountCollection[MAXACCOUNT];
int curAccount = 0;
void InsertAccount(FILE *fp)
{
BANKACCOUNT newaccount;
printf("please input the account information\n");
printf(">>account num:");
scanf("%d",&(newaccount.account));
printf(">>key:");
scanf("%d",&(newaccount.key));
printf(">>name:");
scanf("%s",newaccount.name);
printf(">>balance:");
scanf("%f",&(newaccount.balance));
fseek(fp,0L,SEEK_END);
fprintf(fp,"%d %d %s %.2f\n",newaccount.account,newaccount.key,newaccount.name,newaccount.balance);
}
void GetAccount(FILE *fp)
{
int accountnum;
int key;
char name[32];
float balance;
int i =0,j;
char buffer[BUFFERSIZE];
int len;
curAccount = 0;
fseek(fp,0,SEEK_SET);
while(!feof(fp)) /* 因为feof()最后会读2遍,所以最后curAccount多加了1 */
{
fscanf(fp,"%d %d %s %f",&accountnum,&key,name,&balance);
accountCollection[curAccount].account = accountnum;
accountCollection[curAccount].key = key;
strcpy(accountCollection[curAccount].name ,name);
accountCollection[curAccount].balance = balance;
curAccount++;
}
}
void ListAccount(FILE *fp)
{
int i =0;
printf("There is %d accounts at all:\n",curAccount-1);/* curAccount减去多加的1 */
for(i = 0;i< curAccount-1;i++)
{
printf("ACCOUNT[%d]:\n",i+1);
printf("account:%d\n",accountCollection[i].account);
printf("name:%s\n",accountCollection[i].name);
printf("balance:%.2f\n",accountCollection[i].balance);
}
}
int SearchAccount(FILE *fp,int accountnum)
{
int i =0;
for(i = 0;i< curAccount-1;i++)
{
if(accountCollection[i].account == accountnum)
{
printf("ACCOUNT[%d]:\n",i+1);
printf("account:%d\n",accountCollection[i].account);
printf("name:%s\n",accountCollection[i].name);
printf("balance:%.2f\n",accountCollection[i].balance);
return 1;
}
}
return 0;
}
void DelAccount(FILE *fp,int accountnum)
{
int i;
if(SearchAccount(fp,accountnum)==0)
printf("Can't find the account\n");
else
{
for(i = 0;i<curAccount-1;i++)
{
if(accountCollection[i].account != accountnum)
fprintf(fp,"%d %d %s %.2f\n",accountCollection[i].account,accountCollection[i].key,accountCollection[i].name,accountCollection[i].balance);
}
printf("delete successfully!\n");
}
}
int main()
{
FILE *fp;
int accountnum;
int i;
do{
system("cls"); //清屏
puts("********************************************");
puts("* You can choose : *");
puts("* 1 : Insert a new Account *");
puts("* 2 : List all Accounts *");
puts("* 3 : Find a Account *");
puts("* 4 : Delete a Account *");
puts("* 5 : quit *");
puts("********************************************");
printf("Please input your choice:");
scanf("%d",&i);
system("cls"); //清屏
switch(i)
{
case 1:
if(!(fp = fopen("account.txt","a+")))
{
printf("can't open the file account.txt\n");
exit(0);
}
InsertAccount( fp);
printf("press any key to continue.....\n");
getch();
fclose(fp);
break;
case 2:
if(!(fp = fopen("account.txt","r")))
{
printf("can't open the file account.txt\n");
exit(0);
}
GetAccount(fp);
ListAccount(fp);
fclose(fp);
printf("press any key to continue.....\n");
getch();
break;
case 3:
printf("please input the account num:\n");
scanf("%d",&accountnum);
if(!(fp = fopen("account.txt","r")))
{
printf("can't open the file account.txt\n");
exit(0);
}
GetAccount(fp);
if(!SearchAccount(fp,accountnum))
printf("There is not the account:%d\n",accountnum);
fclose(fp);
printf("press any key to continue.....\n");
getch();
break;
case 4:
printf("please input the account num:\n");
scanf("%d",&accountnum);
if(!(fp = fopen("account.txt","r")))
{
printf("can't open the file account.txt\n");
exit(0);
}
GetAccount(fp);
fclose(fp);
if(!(fp = fopen("account.txt","w+")))
{
printf("can't open the file account.txt\n");
exit(0);
}
DelAccount(fp,accountnum);
fclose(fp);
printf("press any key to continue.....\n");
getch();
break;
default:
break;
}
}while(i != 5);
return 0;
}
账户数据文件名已经设定为account.txt,这个文件要和上面这个程序放在同一个文件夹下面,不然就得用绝对路径(比如"d:\\book\\account.txt"),account内容可以用记事本打开自己改动,然后运行程序后就可以在程序中添加或删除
⑷ C语言 问卷调查的数据统计
C语言 问卷调查的数据统计 可以提供
⑸ 《C语言程序设计》课程作业二答案
第四题上面那些是作什么的?
第四题:1. d=1 k++ k<=n
2. x>=0 x<amin
3. float y=1 y*=i float s=1
4. (8) r (9)r=m%n (10)gcd=n
第五题:
#include "stdio.h"
#define N 8
void main()
{
int i,j,a[N][N];
for(i=0;i<N;i++)
a[i][0]=a[i][i]=1;
for(i=2;i<N;i++)
{
for(j=1;j<i;j++)
a[i][j]=a[i-1][j]+a[i-1][j-1];
}
for(i=0;i<N;i++)
{
for(j=0;j<=i;j++)
printf("%3d",a[i][j]);
printf("\n");
}
}
2.
#include "stdio.h"
#define N 100
void main()
{
int i,sum=0;
for(i=2;i<=N;i+=2)
sum+=i;
printf("sum=%d\n",sum);
}
⑹ 想用C语言设计一个统计调查问卷的程序。想法是这样的:把所有调查对象的答案存入一个二维数组中,列为题
#include<stdio.h>
void main(){
int x[10][6];//存选项,10代表10个题,6代表6个人的答案
int y[10][4];//存统计的数量,10代表10个题,4代表ABCD这四个选项
int i=0,j=0;
//输入答案,如果要选中A就输入1,B = 2,C=3 D=4,每输完六个人的答案后回车下一题
for(i=1;i<=10;i++) {
printf("第%d题答案有:",i);
for(j=0;j<6;j++){
y[i][j]=0;
scanf("%d",&x[i][j]);
}
}
//循环判断
for(i=1;i<=10;i++){
for(j=0;j<6;j++){
if(x[i][j] == 1){
y[i][0]++;
}
if(x[i][j] == 2){
y[i][1]++;
}
if(x[i][j] == 3){
y[i][2]++;
}
if(x[i][j] == 4){
y[i][3]++;
}
}
}
for(i=1;i<=10;i++){
printf("第%d题选A的人有 %d 个:
",i,y[i][0]);
printf("-----选B的人有 %d 个:
",y[i][1]);
printf("-----选C的人有 %d 个:
",y[i][2]);
printf("-----选D的人有 %d 个:
",y[i][3]);
}
}
//运行,每个答案输入六次(我这个是测试,输入的4次),按回车进入下一题同样输入六个人的答案
⑺ 怎样用C语言统计调查问卷
既然已经实现了,就需要说一下你想怎么改,不然让回答者如何提供帮助?
给出一个修改建议吧:原始数据不要从键盘输入,改为从文本文件中读取,这样更加接近于实际应用。
⑻ 用C语言设计问卷调查系统,求代码,华南农业大学软件工程大一课程设计,华农做过这题目的师兄师姐帮帮忙
C语言设计问卷调查系统这方面的我可以。
⑼ C语言程序设计课程形成性考核册答案
A
B
B
A