1. 谁能给我一个80行的c语言程序。要简单点的,大一新生,拜托了
我刚写的,给你热身,,
#include <stdio.h>
void move(char *p,int i);
void remove(char *a,char f);
int main()
{
int i;
char a[60],f;
puts("输入字符串:");
gets(a);
puts("输入要删除的字符:");
f=getchar();
remove(a,f);
puts("删除后:");
puts(a);
puts("输入需要互换的前几个数:");
scanf("%d",&i);
move(a,i);
puts("互换后:");
puts(a);
return 0;
}
void remove(char *a,char f)
{ char *b=a;
while(*b!='\0')
{
if(*b!=f) { *a=*b;a++;}
b++;
}
*a=*b;//把字符串标志写进去
}
void move(char *p,int i)
{
char *a=p+i,*b=a,f;
while(p!=a) //a记录开始位置 b也记录开始位置保持不变 作为循环结束条件
{
f=*a;
*a=*p;//互换 把第一个移到开始位置 把开始位置的字符作为前面字符出现
*p=f;
while(*(a+1)!='\0')//通过循环把它传到最后面 那么此时开始位置又出现新的字符 注意是*(a+1)!='\0'而不是*a!='\0'
{
f=*a;
*a=*(a+1);
*(a+1)=f;
a++;
}
a=b;//把a置初始位置
p++;//移动下一个需要移动到最后面的字符
}
}
2. 求一个80--100行左右的简单些的C语言程序!
可以对输入的学生信息:学号 名字 性别 分数,然后根据分数排名次输出,都学完C了这个应该可以做出来吧
3. 急求一个c语言的大约80行的代码,内容不限,易理解就好(是c语言,不是c++)谢谢
include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define NUM 10
/*int perfect_num(int num){
int x=1,y=0;
while(x<num && x>0){
if(num%x==0){
y=y+x;
}
x=x+1;
}
printf("y=%d\n",y);
if(y==num){
return num;
}
}
int main(){
int return_num=0,num=1;
for(;num<NUM;num++){
return_num=perfect_num(num);
printf("perfect num is %d\n",return_num);
}
}
int main(){
int a=2,b;
b=(2*a,3,a-3);
printf("\nb=%d\n",b);
}
int main(){
int a=2,b=1,c=3;
printf("最大值为%d\n",a>b?(a>c?a:c):(b>c?b:c));
}
int main(){
int a=11;
int b=0x11;
printf("%d\n",a>b?a:b);
}
#include <stdio.h>
int main()
{
int x; double y;
while(scanf("%d",&x)!=EOF)
{
switch (x/100000)
{
case 0:
case 1:y=x*0.1;break;
case 2:y=100000*0.1+100000*0.075;break;
case 3:
case 4:y=100000*0.1+100000*0.075+200000*0.1+200000*0.05;break;
case 5:
case 6:y=100000*0.1+100000*0.075+200000*0.1+x-200000*0.05+200000*0.1+400000*0.03;break;
case 7:
case 8:
case 9:
case 10:y=100000*0.1+100000*0.075+200000*0.1+200000*0.05+200000*0.1+400000*0.03+200000*0.1+600000*0.015;break;
default:y=100000*0.1+100000*0.075+200000*0.1+200000*0.05+200000*0.1+400000*0.03+1000000*0.01;break;
}
printf("%.0f\n",y);
}
return 0;
}
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void main(){
srand(5);
printf("%d\n",rand());
printf("%d\n",rand());
printf("%d\n",rand());
printf("%d\n",rand());
}
//约瑟夫环问题
void main(){
int total,num,last,i;
i=0;last=0;
printf("请输入人数\n");
scanf("%d",&total);
printf("请输入数数的数字\n");
scanf("%d",&num);
for(i=2;i<=total;++i){
last=(last+num)%i;
printf("i=%d,last=%d\n",i,last);
}
printf("The last one is:%d\n",last+1);
}
4. 急求八十行的c语言程序一份
如果只要行数的话,连续80行的printf("hi\n");可以吗?或者用80个printf写一段话?
5. 求一简单的c语言编程题80行左右 大一用的 c++环境下运行的 简单点的
以下是统计26个英文小写字母出现的次数
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void Stat(char *str,int count[])
{
int i;
for(i=0;i<26;i++)count[i]=0;
for(i=0;i<strlen(str);i++)
{
if(str[i]=='a')count[0]++;
else if(str[i]=='b')count[1]++;
else if(str[i]=='c')count[2]++;
else if(str[i]=='d')count[3]++;
else if(str[i]=='e')count[4]++;
else if(str[i]=='f')count[5]++;
else if(str[i]=='g')count[6]++;
else if(str[i]=='h')count[7]++;
else if(str[i]=='i')count[8]++;
else if(str[i]=='j')count[9]++;
else if(str[i]=='k')count[10]++;
else if(str[i]=='l')count[11]++;
else if(str[i]=='m')count[12]++;
else if(str[i]=='n')count[13]++;
else if(str[i]=='o')count[14]++;
else if(str[i]=='p')count[15]++;
else if(str[i]=='q')count[16]++;
else if(str[i]=='r')count[17]++;
else if(str[i]=='s')count[18]++;
else if(str[i]=='t')count[19]++;
else if(str[i]=='u')count[20]++;
else if(str[i]=='v')count[21]++;
else if(str[i]=='w')count[22]++;
else if(str[i]=='x')count[23]++;
else if(str[i]=='y')count[24]++;
else if(str[i]=='z')count[25]++;
}
}
int main(void)
{
char str[10000];
int i,count[26];
printf("请输入a~z的字符串:\n");
gets(str);
Stat(str,count);
for(i=0;i<26;i++)
printf("%c:%d\n",i+'a',count[i]);
system("pause");
return 0;
}
祝你愉快!
6. C语言80行左右的编程
以前写的在给出n_gs=6个aa[]数中挑选n_js=3个数,其加减运算后的和的绝对值在n_fw1=8,n_fw2=10 范围内所有组合,输出运算过程,其最后结果输出到jg.txt
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int no[40],aa[]={1,2,3,4,5,6};
int MAXSIZE = 40;
unsigned short n_js=3,n_gs=6;
float n_fw1=8,n_fw2=10;
float n_l1=0,n_l2=0,n_l3=0,n_sum;
float n_fw11,n_fw12;
int N,M;
int A[80], B[80],str[40],ss[40];
char www3[80];
char www1='X',www2='=';
FILE *fp;
void comb_all()
{
unsigned short i,j,k,l;
short bound;
n_sum = 0;
for (i=0 ; i<n_js; ++i)
{ str[i]=B[i];
ss[i]=-1;
n_sum=n_sum+B[i];
}
n_fw12=(n_sum-n_fw1)/2;
n_fw11=(n_sum-n_fw2)/2;
bound = (1 << n_js);
for (i = 1; i < bound; ++i)
{
unsigned short mask = 1;
n_l1 = 0;
for (j = 0; j < n_js; ++j)
{
if (i & mask)
ss[j]=j;
www3[j]='+';
mask <<= 1;
}
for (k=0;k<n_js;++k)
{ if (ss[k] > -1)
{
n_l1=n_l1+str[k];
www3[k]='-';
ss[k]=-1;
}
}
if ((n_l1>n_fw11)&&(n_l1<n_fw12))
{/*输出*/
for (l=0 ;l<n_js;++l)
{ fprintf(fp,"%c%c%d",www3[l],www1,A[l]+1);
}
fprintf(fp,"%c%f\n",www2,n_sum-n_l1*2);
}
}
}
/* 待删除 */
void Print()
{
int i,l;
float n_s1=0;
for (i = 0; i < n_js; ++i)
{n_s1=n_s1+B[i];
printf("%d %d---", B[i],A[i]);}
printf("fffffffffff\n");
if (n_s1> n_fw2)
{ comb_all();}
else if (n_s1>n_fw1)
{for (l=0 ;l<n_js;++l)
{ fprintf(fp,"%c%c%d",www3[l],www1,A[l]+1);
}
fprintf(fp,"%c%f\n",www2,n_s1);}
}
void Com(int n, int m)
{
int i;
for (i = n; i >= m; --i)
{
B[m] = aa[i];
A[m] = no[i];
if (m > 0)
Com(i-1,m-1);
else
Print();
}
}
/* 待删除 */
int main()
{
int i;
if((fp=fopen("jg.txt","w"))==NULL)
{printf("cannot open this file \n");
exit(0);
}
for(i=0;i<40;i++) /*对A[N]进行初始化,*/
{
no[i]=i;
A[i]=i;
www3[i]='+';
}
if (n_gs > MAXSIZE)
return 1; /*越界*/
Com(n_gs-1,n_js-1);
/* comb_all();*/
fclose(fp);
return 0;
}
7. 急!求一c语言程序,50-80行的,最好是原创,简易点的
亲,以下为一简单的猜数游戏,你可以看看:
#include"stdio.h"
#include"stdlib.h"
#include"time.h"
void main()
{
long a,b,c,d,i,f;
char e;
there:
printf("下面开始猜数游戏,请你选择你要猜的范围\n");
printf("范围最小为50,且你有10次机会\n");
here:
printf("请选择你要猜的下限:");
while((scanf("%ld",&a))!=1)
{
getchar();
printf("对不起,你输入的不是整数,请输入一个整数做为下限\n");
}
printf("请选择你要猜的上限:");
while((scanf("%ld",&b))!=1)
{
getchar();
printf("对不起,你输入的不是整数,请输入一个整数做为上限\n");
}
if(b<a)
{
f=a;
a=b;
b=f;
}
if(b-a<50)
{
printf("对不起,你输入的范围小于50,请重新输入上下限\n");
goto here;
}
srand(time(NULL));
c=rand()%(b-a+1)+a;
for(i=1;i<=10;i++)
{
printf("请给出你的第%ld次选择:",i);
if((scanf("%ld",&d))!=1)
{
getchar();
printf("对不起,您输入的数据不符合游戏规则,请输入%ld到%ld的整数\n",a,b);
printf("您还有%ld次机会,请再接再厉\n",10-i);
}
else if(d>b||d<a)
{
printf("对不起,您猜的数超出了范围,请输入%ld到%ld的整数\n",a,b);
printf("您还有%ld次机会,请再接再厉\n",10-i);
}
else if(d>c)
{
if(d-c<10)
{
printf("您猜的数大了一点点,胜利就在眼前\n");
printf("您还有%ld次机会,请再接再厉\n\n",10-i);
}
else
{
printf("你猜的数过大了\n");
printf("您还有%ld次机会,请再接再厉\n\n",10-i);
}
}
else if(d<c)
{
if(c-d<10)
{
printf("您猜的数小了一点点,胜利就在眼前\n");
printf("您还有%ld次机会,请再接再厉\n\n",10-i);
}
else
{
printf("你猜的数过小了\n");
printf("您还有%ld次机会,请再接再厉\n\n",10-i);
}
}
else
{
printf("\n\n恭喜你,猜对了!\n");
printf("你是否还想再玩这个游戏?\n\n");
printf("如果想继续玩,请按‘Y’(不区分大小写)\n");
printf("如果不想再玩了,请按其他任意键退出\n");
printf("您的选择是:");
getchar();
scanf("%c",&e);
if(e=='Y'||e=='y')
goto there;
else
break;
}
}
if(i==11){
printf("对不起,您的机会已经用完了\n");
printf("您可以选择重新再玩或退出\n");
printf("按‘Y’(不区分大小写)是重新再玩,其他任意键退出\n");
printf("您的选择是:");
getchar();
scanf("%c",&e);
if(e=='Y'||e=='y')
goto there;
}
}
8. C语言不少于80行的程序语句
#include<stdio.h>
intmain(void)
{
inti;
intyear,total,total1,total2;
intmon1,mon2;
intday1,day2;
intyear1[12]={31,28,31,30,31,30,31,31,30,31,30,31};
intyear2[12]={31,29,31,30,31,30,31,31,30,31,30,31};
total1=total2=0;
printf("请输入您要计算哪一年:");
scanf("%d",&year);
if(year%4==0&&year%100!=0||year%400==0)//判断此年是否是闰年,如果是闰年执行下面的语句
{
printf("%d年是闰年. ",year);
printf("请输入第一个月份:");
while(scanf("%d",&mon1)==1)
{
if(mon1>12||mon1<=0)
{
printf("您的输入有误,请重新输入! ");
printf("请输入第一个月份:");
}
else
break;
}
printf("请输入此月的第几天:");
while(scanf("%d",&day1)==1)
{
if(mon1==2)
{
if(day1>29||day1<=0)//闰年二月有29天
{
printf("您的输入有误,请重新输入! ");
printf("请输入此月的第几天:");
}
else
break;
}
else
break;
}
printf("请输入第二个月份:");
while(scanf("%d",&mon2)==1)
{
if(mon2>12||mon2<=0)
{
printf("您的输入有误,请重新输入! ");
printf("请输入第二个月份:");
}
else
break;
}
printf("请输入此月的第几天:");
while(scanf("%d",&day2)==1)
{
if(mon2==2)
{
if(day2>29||day2<=0)
{
printf("您的输入有误,请重新输入! ");
printf("请输入此月的第几天:");
}
else
break;
}
else
break;
}
for(i=0;i<mon1-1;i++)
total1+=year1[i];
total1+=day1;
for(i=0;i<mon2-1;i++)
total2+=year1[i];
total2+=day2;
if(total1>total2)
total=total1-total2;
else
total=total2-total1;
printf("这两个日期共相差%d天! ",total);
}
else//不是闰年的情况
{
printf("%d年不是闰年. ",year);
printf("请输入第一个月份:");
while(scanf("%d",&mon1)==1)
{
if(mon1>12||mon1<=0)
{
printf("您的输入有误,请重新输入! ");
printf("请输入第一个月份:");
}
else
break;
}
printf("请输入此月的第几天:");
while(scanf("%d",&day1)==1)
{
if(mon1==2)//平年二月有28天
{
if(day1>28||day1<=0)
{
printf("您的输入有误,请重新输入! ");
printf("请输入此月的第几天:");
}
else
break;
}
else
break;
}
printf("请输入第二个月份:");
while(scanf("%d",&mon2)==1)
{
if(mon2>12||mon2<=0)
{
printf("您的输入有误,请重新输入! ");
printf("请输入第二个月份:");
}
else
break;
}
printf("请输入此月的第几天:");
while(scanf("%d",&day2)==1)
{
if(mon2==2)
{
if(day2>28||day2<=0)
{
printf("您的输入有误,请重新输入! ");
printf("请输入此月的第几天:");
}
else
break;
}
else
break;
}
for(i=0;i<mon1-1;i++)
total1+=year2[i];
total1+=day1;
for(i=0;i<mon2-1;i++)
total2+=year2[i];
total2+=day2;
if(total1>total2)
total=total1-total2;
else
total=total2-total1;
printf("这两个日期共相差%d天! ",total);
}
return0;
}
这个应该不会有雷同! 而且够长
9. 求一C语言程序,80行足矣,随便什么不用太难~。
看看行不行
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct _employee
{
int number;
char * name;
int sex;
int age;
}em;
struct simple
{
char * name;
int age;
};
#define NUM 10
em array[NUM];
int nowCount = 0;
int delEm(int num)
{
int flag = 0;
int i, j;
for(i = 0; i < nowCount; i++)
{
if(array[i].number == num)
{
for(j = i + 1; j < nowCount; ++j)
{
array[j-1] = array[j];
}
flag = 1;
--nowCount;
}
}
return flag;
}
int insert(em e)
{
if(nowCount < NUM)
{
array[nowCount] = e;
++nowCount;
return 1;
}
return 0;
}
void input(em *e)
{
printf("请输入职工编号:");
scanf("%d", &(e->number));
printf("请输入职工姓名:");
e->name = (char*)malloc(15);
memset(e->name, 0, 15);
scanf("%s", e->name);
printf("请输入职工性别(1代表男,0代表女):");
scanf("%d", &(e->sex));
printf("请输入职工年龄:");
scanf("%d", &(e->age));
printf("\n");
}
void print()
{
int i;
printf("\n现在共有%d个职工的信息.\n", nowCount);
for(i = 0; i < nowCount; ++i)
{
printf("第%d个职工的信息如下:\n", i + 1);
printf("职工序号:%d\n", array[i].number);
printf("职工姓名:%s\n", array[i].name);
printf("职工性别:%s\n", (array[i].sex ? "男" : "女"));
printf("职工年龄:%d\n", array[i].age);
printf("\n");
}
}
void main()
{
int flag = 1;
int num;
em e;
int choice = 0;
while(flag)
{
printf("\n");
printf("--------------------菜单---------------------\n");
printf("1.输入职工信息\n");
printf("2.显示现有职工信息\n");
printf("3.删除某职工信息\n");
printf("4.退出\n");
printf("请输入操作代号:");
scanf("%d", &choice);
printf("\n");
switch(choice)
{
case 1:
printf("现在共有%d个职工的信息,共可以存%d个,最多还可以输入%d个\n", nowCount, NUM, NUM - nowCount);
if(nowCount == NUM)
{
printf("人数已经达上限%d个.不再接受输入", NUM);
break;
}
input(&e);
insert(e);
break;
case 2:
print();
break;
case 3:
printf("请输入要删除的职业序号:");
scanf("%d", &num);
if(delEm(num))
printf("删除完成\n");
else
printf("删除失败\n");
break;
case 4:
flag = 0;
break;
default:
break;
}
}
getchar();
}
10. 求一个80行C语言程序
#include "time.h"
#include "stdlib.h"
#include "stdio.h"
#include "conio.h"
main()
{
char c;
clock_t start,end;
time_t a,b;
double var;
int i,guess;
srand(time(NULL));
printf("do you want to play it.('y' or 'n') \n");
loop:
while((c=getchar())=='y')
{
i=rand()%100;
printf("\nplease input number you guess:\n");
start=clock();
a=time(NULL);
scanf("%d",&guess);
while(guess!=i)
{
if(guess>i)
{
printf("please input a little smaller.\n");
scanf("%d",&guess);
}
else
{
printf("please input a little bigger.\n");
scanf("%d",&guess);
}
}
end=clock();
b=time(NULL);
printf("\1: It took you %6.3f seconds\n",var=(double)(end-start)/18.2);
printf("\1: it took you %6.3f seconds\n\n",difftime(b,a));
if(var<15)
printf("\1\1 You are very clever! \1\1\n\n");
else if(var<25)
printf("\1\1 you are normal! \1\1\n\n");
else
printf("\1\1 you are stupid! \1\1\n\n");
printf("\1\1 Congralations \1\1\n\n");
printf("The number you guess is %d",i);
}
printf("\ndo you want to try it again?(\"yy\".or.\"n\")\n");
if((c=getch())=='y')
goto loop;
}