本文目录一览:
- 1、一个简单的C语言作业
- 2、C语言作业
- 3、一个简单的C语言作业!
一个简单的C语言作业
void swap(Person *array,int n){
int temp=array[0]-height;
array[0]-height=array[n-1]-height;
array[n-1]-height=array[0]-height;
}
C语言作业
#include "stdio.h"
int main(int argc,char ** argv)
{
sign();
}
void sign()
{
char ch;
printf("Input character:");
scanf("%c",ch);
if(ch'a' ch'z')
printf("%c %c",ch,ch-32);
else if(ch'A' ch'Z')
printf("%c %c",ch,ch+32);
else
printf("The characters not letter");
printf("\n");
}
void triangle()
{
double a = 0.0,b = 0.0,c = 0.0;
printf("input triangle :");
scanf("%f %f %f", a, b, c);
if( a 0.0 b 0.0 c 0.0)
{
if(( a + b c) || ( a + c ) b || ( c + b ) a) //两边之和大于第三边
{
if(a == b || b == c || c == a)
printf("%lf %lf %lf ,it is double border triangle. ",a , b, c);
else
{
printf("This is triangle , but not double border triangle.");
}
}
else
{
printf("This is not double border triangle");
}
}
else
{
printf("This is not triangle.");
}
}
一个简单的C语言作业!
把源程序给你吧。
#includestdio.h
#includemalloc.h
typedef struct node
{ int num;
struct node *next;
}linklist;
主程序如下:
#include"h1.h"
/* 建立单循环链表函数 */
linklist *creat(int n)
{
int k;
linklist *head, *r, *p;
p=(linklist *)malloc(sizeof(linklist));
head=p;
p-num=1;
printf("输入第一个人的密码:\n");
scanf("%d",p-cipher);
r=p;
p-next=p;
for(k=2;k=n;k++)
{
p=(linklist *)malloc(sizeof(linklist));
p-num=k;
printf("输入密码:\n");
scanf("%d",p-cipher);
r-next=p;
r=p;
}
p-next=head;
return(head);
}
/* 选择出列编号 */
linklist *select(linklist *head, int m)
{ linklist *p,*q;
int k;
q=head;
k=1;
p=q-next; //q为p的前趋指针,p指向当前报数的人
while(q!=p)
{
k=k+1; //报一次数
if(k%m==0)
{ printf("出列的序号为:%d\n",p-num);
m=p-cipher;
q-next=p-next; //对应的结点从链表中删除
free(p);
k=0;
p=q-next;
}
else{
q=p;
p=p-next; // p指向当前报数的人
}
}
head=p;
return(head);
}
void main()
{ int n,m;
linklist *head;
printf("Input n:\n");
scanf("%d",n);
printf("Input the number to call:\n");
scanf("%d",m);
head=creat(n);
head=select(head,m);
printf("The last one is:%d\n",head-num);
}