1. c语言作业,求解答,高额悬赏,只要原创,不要粘贴复制的!!!
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
FILE*fp;
intn=0;
voidmenu();
voidadd();
voidfind();
voidsee();
voidxiugai();
voiddele();
voidreadfile();
voidwritefile();
structtongxunlu
{
charname[20];
charphone[20];
charadder[20];
}txl[100];
voidreadfile()
{
FILE*fp;
if((fp=fopen("e:\通讯录.txt","r"))==NULL)
{
return;
}
else
{
printf("已经发现所需文件...... ");
printf("请继续 ");
}
fseek(fp,0,2);
if(ftell(fp)>0)
{
rewind(fp);
for(n=0;!feof(fp)&&fread(&txl[n],sizeof(structtongxunlu),1,fp);n++);
printf("文件准备完成,请继续 ");
getchar();
}
}
voidmenu()
{
intm;
system("cls");
printf("---------------------操作菜单---------------------- ");
printf(" 0.退出 ");
printf(" 1.输入联系人信息 ");
printf(" 2.查找联系人信息 ");
printf(" 3.浏览联系人信息 ");
printf(" 4.修改联系人信息 ");
printf(" 5.保存联系人信息 ");
printf(" 6.删除联系人信息 ");
printf("--------------------------------------------------- ");
printf("请输入你的选择: ");
scanf("%d",&m);
switch(m)
{
case0:
exit(0);
break;
case1:
add();
break;
case2:
find();
break;
case3:
see();
break;
case4:
xiugai();
break;
case5:
writefile();
break;
case6:
dele();
break;
default:
menu();
break;
}
}
voidadd()
{
printf(" ---------------请输入联系人信息-----------------");
printf(" 输入联系人姓名:");
scanf("%s",txl[n].name);
printf(" 输入联系人电话:");
scanf("%s",txl[n].phone);
printf(" 输入联系人地址:");
scanf("%s",txl[n].adder);
n++;
printf(" 是否继续添加联系人?(Y/N):");
if(getch()=='y')
add();
return;
}
voidfind()
{
intm=0;
inti;
charxingming[20];
printf(" 请输入您要查找的姓名:");
scanf("%s",xingming);
for(i=0;i<n;i++)
{
if(strcmp(txl[i].name,xingming)==0)
{
printf(" ------------以下是您查找的联系人信息---------------");
printf(" 姓名:%s",txl[i].name);
printf(" 电话:%s",txl[i].phone);
printf(" 地址:%s",txl[i].adder);
m++;
getch();
return;
}
}
if(m==0)
{
printf("没有此联系人信息 ");
getch();
return;
}
}
voidxiugai()
{
intc;
inti,m=0;
charxingming[20];
printf("请输入要修改的联系人姓名: ");
scanf("%s",xingming);
if(n==0)
{
printf("没有此联系人 ");
printf("请继续 ");
getch();
m++;
return;
}
for(i=0;i<n;i++)
{
if(strcmp(txl[i].name,xingming)==0)
{
printf("以下是你想要修改联系人的信息 ");
printf(" 姓名:%s ",txl[i].name);
printf(" 电话:%s ",txl[i].phone);
printf(" 地址:%s ",txl[i].adder);
printf("是否修改此联系人信息y/n ");
}
if(getch()=='y')
{
printf("1.修改联系人姓名 ");
printf("2.修改联系人电话 ");
printf("3.修改联系人地址 ");
printf("请输入选择: ");
scanf("%d",&c);
switch(c)
{
case1:{printf("请输入新的姓名 ");
scanf("%s",txl[i].name);}break;
case2:{printf("请输入新的电话 ");
scanf("%s",txl[i].phone);}break;
case3:{printf("请输入新的地址 ");
scanf("%s",txl[i].adder);}break;
default:break;
}
}
if(m==0)
{
printf("没有查找到此联系人信息 ");
printf("是否继续修改?(Y/N): ");
if(getch()=='y')
xiugai();
return;
}
}
} //缺少一个大括号
voiddele()
{
inti,m,n,d=0,a=0;
charxingming[20];
printf("请输入要删除联系人姓名:");
scanf("%s",xingming);
for(i=0;i<n;i++)
{
if(strcmp(txl[i].name,xingming)==0)
{
printf("以找到此联系人 ");
printf("姓名:%s ",txl[i].name);
printf("电话:%s ",txl[i].phone);
printf("地址:%s ",txl[i].adder);
printf("是否删除?(y/n) ");
if(getch()=='y')
{
for(m=i;m<n-1;m++)
txl[m]=txl[m+1];
n--;
d++;
printf("删除成功 ");
printf("是否继续删除其他联系人?y/n ");
if(getch()=='y')
dele();}
return;
}
}
} //缺少一个大括号
voidsee()//多了一个分号
{
inti;
system("cls");
if(n!=0)
{
printf(" ----------查询通讯录所有联系人信息-------------");
for(i=0;i<n;i++)
{
printf(" 姓名:%s",txl[i].name);
printf(" 电话:%s",txl[i].phone);
printf(" 地址:%s",txl[i].adder);
if(i+1<n)
{
printf(" -----------------------");
system("pause");
}
}
printf(" ---------------------------------------------");
}
else
printf(" 通讯录中无任何纪录");
printf(" 按任意键返回主菜单:");
getch();
}
voidwritefile()
{
inti;
if((fp=fopen("e:\通讯录.txt","w"))==NULL)
{
printf("没有找到文件 ");
}
for(i=0;i<n;i++)
{
if(fwrite(&txl[i],sizeof(structtongxunlu),1,fp)!=1)
{
printf("写入文件错误! ");
}
}
fclose(fp);
printf("文件保存 ");
}
intmain()
{
readfile();
while(1)
{
menu();
}
return0;
}
2. C语言本人刚学C语言 有点不懂
第一个:
#include"stdio.h"
main()
{
float a,b,c,d;
scanf("%f %f %f %f",&a,&b,&c,&d);
printf("%f\n",(a+b+c+d)/4);
}
第二个:
#include"stdio.h"
#define PI 3.1415926
main()
{
float r;
while(scanf("%f",&r))
printf("%f %f\n",PI*r*r,2*PI*r);
}
简单吗?如果还不够简单,我再给你写个更简单的.
加油哦...支持新手加入这个行当...
3. C语言不懂,求高手解释下面程序的意思,希望详细点,谢谢!
struct st
{int n;
float x;
}*p; //这有两层意思,分解开来就是:
1) 声明一个结构体struct st{int n; float x;}
2) 定义一个st结构体指针变量struct st *p;
4. 求一个c语言程序,必须原创,越简单越好,微信我加你,25元,(可以商量)
so easy..............
5. 我想学c语言,请高手指教我一下
下载地址
http://hi..com/%D3%A5%DE%C4/blog/item/2a8d0df7180b9b4c342acc5e.html
谭浩强《C程序设计》上机试题可以下载
http://hi..com/%D3%A5%DE%C4/blog/item/1b8c968f649f4e639e2fb49c.html
其他C语言资料参考书,如趣味一百例
http://hi..com/%D3%A5%DE%C4/blog/item/019bcafefade81c2b58f3159.html
基础C视频教程
http://hi..com/%D3%A5%DE%C4/blog/item/31e3eac0cc57f3d738db495f.html
郝斌C语言视频
http://hi..com/%D3%A5%DE%C4/blog/item/df9b5a26c00bc1b84623e894.html
6. C语言不太懂,求原创
#include<stdio.h>
#include<limits.h>
#defineM3
intmain()
{
inta[SHRT_MAX]={0},i=0,k=0,n,c;
scanf("%d",&n);
if(n>SHRT_MAX)return1;
for(c=n;c>1;i++)
if(!(a[i%n]||++k%M))a[i%n]=c--;
for(i=0;i<n;i++)
if(!a[i])printf("%d",i+1);
return0;
}
7. 求大神解答C语言问题,要原创的,万分感谢!!
#include<stdio.h>
#include<stdlib.h>
int main()
{
float a,b;
int yunsuanfu;
printf("请输入要计算的2个操作数:\n");
scanf("%f",&a);
scanf("%f",&b);
printf("运算的类型有:\n");
printf("\t\t1+\n");
printf("\t\t2-\n");
printf("\t\t3*\n");
printf("\t\t4/\n");
printf("请输出你要的运算类型:\n");
scanf("%d",&yunsuanfu);
float c1=a+b;
float c2=a-b;
float c3=a*b;
float c4=a/b;
for(int i=0;i<40;i++)
printf("-");
printf("/n");
switch(yunsuanfu)
{
case 1: printf("%f\n",c1); break;
case 2: printf("%f\n",c2); break;
case 3: printf("%f\n",c3); break;
case 4:
if (b==0)
printf("除数不能为0\n");
else printf("%f\n",c4); break;
}
return 0;
8. 求原创C语言程序....100行左右!内容不限····急急急。。。
#include <stdio.h>
#define NULL 0
#include <stdlib.h>
struct node
{
int num;
struct node *next;
};
struct node *creat()
{
struct node *head=NULL,*p1,*p2;
int n=0;
p1=p2=(struct node *)malloc(sizeof(struct node));
scanf("%d",&p1->num);
while(p1->num!=NULL)
{
n++;
if(n==1)head=p1;
else
p2->next=p1;
p2=p1;
p1=(struct node *)malloc(sizeof(struct node));
scanf("%d",&p1->num);
}
p2->next=NULL;
return head;
}
void put(struct node *head)
{
struct node *p;
p=head;
if(head!=NULL)
while(p!=NULL)
{
printf("%d",p->num);
p=p->next;
}
}
struct node *insert(struct node *head,struct node *stu)
{
struct node *p1,*p2,*p0;
p0=stu;
p1=head;
if(head==NULL)
{
head=p0;p0->next=NULL;
}
else
{
while((p0->num>p1->num)&&(p1->next!=NULL))
{
p2=p1;
p1=p1->next;
}
if(p0->num<=p1->num)
{
if(head==p1)
{
head=p0;
}
else
{
p2->next=p0;
}
p0->next=p1;
}
else
{
p1->next=p0;
p0->next=NULL;
}
}
return head;
}
struct node *del(struct node *head,long num)
{
struct node *p1,*p2;
if(head==NULL)
printf("\nlist null!\n");
p1=head;
while(p1->next!=NULL&&p1->num!=num)
{
p2=p1;
p1=p1->next;
}
if(p1->num==num)
{
if(p1==head)
head=p1->next;
else
p2->next=p1->next;
printf("delete:%ld\n",num);
}
else
printf("%ld not been found!\n",num);
return head;
}
void main()
{
struct node *head,*stu;
long num;
printf("Please input the number:\n");
head=creat();
put(head);
printf("Please input the delete number:\n");
scanf("%ld",&num);
while(num!=0)
{
del(head,num);
put(head);
printf("Please input the delete number:\n");
scanf("%ld",&num);
}
printf("Please input the insert number:\n");
stu=(struct node *)malloc(sizeof (struct node));
scanf("%d",&stu->num);
while(stu->num!=0)
{
head=insert(head,stu);
put(head);
printf("Please input the insert number:\n");
stu=(struct node *)malloc(sizeof (struct node));
scanf("%d",&stu->num);
}
9. C语言求助,刚入门,看不懂,有图片,求详细过程还有答案
这个C语言程序的源代码每一句的功能(见注释),执行结果,程序的功能和执行过程如下
#include<stdio.h>
void main(){
char c;//定义字符变量c
c=getchar();//读入一个字符
while(c!=' '){ //循环直到遇到换行符
if('a'<=c&&c<='w'||'A'<=c&&c<='W') //判断字符变量c是否在a到w之间(包括大小写)
c+=3; //字母向后移3位
else if('x'<=c&&c<='z'||'X'<=c&&c<='Z')//判断字符变量c是否在x到z之间(包括大小写)
c-=23; //字母向前移23位
printf("%c",c); //输出移动后的字母,不换行
c=getchar(); //读入下一个字符
}
printf(" ");//输出换行
}