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(" ");//輸出換行
}