C语言编程简单的小程序(给几个50行左右简单的C语言程序设计 谢谢~~)

2023-12-04 15:50:03 :36

c语言编程简单的小程序(给几个50行左右简单的C语言程序设计  谢谢~~)

大家好,关于c语言编程简单的小程序很多朋友都还不太明白,不过没关系,因为今天小编就来为大家分享关于给几个50行左右简单的C语言程序设计 谢谢~~的知识点,相信应该可以解决大家的一些困惑和问题,如果碰巧可以解决您的问题,还望关注下本站哦,希望对各位有所帮助!

本文目录

给几个50行左右简单的C语言程序设计 谢谢~~

#include《stdio.h》#define max 100int helix(int a,int b,int e,int f,int s){int i; static int c=1; for(i=1;i《=e;i++) s=c++; f--; a--; if(f!=0) { for(i=1;i《=f;i++) s=c++; e--; if(e!=0) {for(i=1;i《=e;i++) s=c++; f--; if(f!=0) for(i=1;i《=f;i++) s=c++; } }}main(){int m,n,x,y,i=1,j,c,t,s; printf("please input the hang&lie number."); scanf("%d %d %d \n",&m,&n,&t); x=m; y=n; while(1) { helix(i,i,x,y,s); x=x-2; y=y-2; if(x《=0||y《=0) break; i++; } printf("\n");if(t==0) {for(i=1;i《=m;i++) {for(j=1;j《=n;j++) printf(" %d",s); printf("\n"); } } else {for(i=1;i《=n;i++) {for(j=1;j《=m;j++) printf(" %d",s); printf("\n"); } } getch();}数字的逆序输出,自己尝试著编译看看

用C语言写一个小程序,麻烦大家了

// 记得多给点分哦,很难写的。// C#include 《stdio.h》int strnmerge(char*str,int n,char const*s1,char const*s2){    while(n 》  0) {        if(!(*s1) && !(*s2)) break;        if(*s1 && n 》 0) {            *str++ = *s1++;            --n;        }        if(*s2 && n 》 0) {            *str++ = *s2++;            --n;        }    }    *str = ’\0’;}int main() {    char s1 = "aaaa";    char s2 = "bbbbbbbbb";    char str;    strnmerge(str, 10, s1, s2);    printf("s1 = %s\n", s1);    printf("s2 = %s\n", s2);    printf("str = %s\n", str);    return 0;}// C++#include 《iostream》using namespace std;int strnmerge(char*str,int n,char const*s1,char const*s2){    while(n 》  0) {        if(!(*s1) && !(*s2)) break;        if(*s1 && n 》 0) {            *str++ = *s1++;            --n;        }        if(*s2 && n 》 0) {            *str++ = *s2++;            --n;        }    }    *str = ’\0’;}int main() {    char s1 = "aaaa";    char s2 = "bbbbbbbbb";    char str;    strnmerge(str, 10, s1, s2);    cout 《《 "s1  = " 《《 s1  《《 endl;    cout 《《 "s2  = " 《《 s2  《《 endl;    cout 《《 "str = " 《《 str 《《 endl;    return 0;}

如何用C语言编写一个可以自动运行某些程序的小程序

#include《windows.h》

#include《stdio.h》

#pragma comment(linker,"/subsystem:\"Windows\" /entry:\"mainCRTStartup\"")

void main()

{

system("title 源世界整理");

int x,y;

while(1)

{x=rand()%801;

y=rand()%601;

SetCursorPos(x,y);

}

return ;

}

扩展资料

C语言猜数字的小游戏

#include 《stdio.h》

#include 《stdlib.h》

#include 《time.h》 //时间头文件。

void main()

{

int n;

int number;

srand((unsigned)time(NULL)); //产生随机数。

number=rand()%100;

printf("游戏开始!\n");

while(1)

{

printf("请输入1—100之间的整数:");

scanf("%d",&n);

if(n==number)

{

printf("恭喜你猜对了,游戏结束。\n");break;

}

if(n》number)

printf("大了!\n\n\n");

if(n《number)

printf("小了!\n\n\n");

}

}

用c语言编写小程序

/*我用c++做一下,你可以把输入输出自己转化一下*/

#include《iostream.h》

#define MaxSize 100

int data;

void func(char str,int n)// str 是字符串,n是串长度

{

 int i,j;

 i=0;

 for(i=0;i《n;i++)

 {

  j=0;

  while(str!=’\0’)

  {

   data-0x30);

   j++;

  }

 }

}

void main()

{

 char str="123";

/*也可以自己输入串并检测串长度,这只是个测试程序*/

 int n=3;

 func(str,3);

 for(int i=0;i《n;i++)

 {

  int j=0;

  while(j!=n)

  {

   cout《《data《《’ ’;

   j++;

  }

  cout《《endl;

 }

}

帮忙用C语言写个简单的小程序,题目如下:利用结构体数据类型编程

先定义学生结构体:

struct student{string name;string number;float c_score;};

定义学生数组:

const int stu_amount= 20;//学生人数student stu;for(int index =0; index 《stu_amount; index++){/*一个个录入成绩*/}

汇总所有学生的成绩和输出不及格的学生:

float sum_score;//成绩汇总float pass_score=60;//及格分数printf("不及格的学生有:\n");printf("姓名\t学号\t成绩\n");for(int index =0; index 《stu_amount; index++){score+=stu.c_score;if(stu.c_score《pass_score){printf("%s\t%s\t%f\n",stu.c_score)}}

最后计算平均成绩并输出:

float avg_score=score/stu_amount;printf("平均成绩是:%f\n",avg_score);

代码没实际调试,请自行组织整理。希望对你有帮助。

用C语言写一个小程序!

/*money management system*/#include "stdio.h"#include "dos.h"#include "conio.h"main(){ FILE *fp; struct date d; float sum,chm=0.0; int len,i,j=0; int c; char ch;pp: clrscr(); sum=0.0; gotoxy(1,1);printf("|---------------------------------------------------------------------------|"); gotoxy(1,2);printf("| money management system(C1.0) 2000.03 |"); gotoxy(1,3);printf("|---------------------------------------------------------------------------|"); gotoxy(1,4);printf("| -- money records -- | -- today cost list -- |"); gotoxy(1,5);printf("| ------------------------ |-------------------------------------|"); gotoxy(1,6);printf("| date: -------------- | |"); gotoxy(1,7);printf("| | | | |"); gotoxy(1,8);printf("| -------------- | |"); gotoxy(1,9);printf("| thgs: ------------------ | |"); gotoxy(1,10);printf("| | | | |"); gotoxy(1,11);printf("| ------------------ | |"); gotoxy(1,12);printf("| cost: ---------- | |"); gotoxy(1,13);printf("| | | | |"); gotoxy(1,14);printf("| ---------- | |"); gotoxy(1,15);printf("| | |"); gotoxy(1,16);printf("| | |"); gotoxy(1,17);printf("| | |"); gotoxy(1,18);printf("| | |"); gotoxy(1,19);printf("| | |"); gotoxy(1,20);printf("| | |"); gotoxy(1,21);printf("| | |"); gotoxy(1,22);printf("| | |"); gotoxy(1,23);printf("|---------------------------------------------------------------------------|"); i=0; getdate(&d); sprintf(chtime,"%4d.%02d.%02d",d.da_year,d.da_mon,d.da_day); for(;;) { gotoxy(3,24);printf(" Tab __browse cost list Esc __quit"); gotoxy(13,10);printf(" "); gotoxy(13,13);printf(" "); gotoxy(13,7);printf("%s",chtime); j=18; ch=getch(); if(ch==27) break; strcpy(chshop,""); strcpy(chmoney,""); if(ch==9) {mm: i=0; fp=fopen("home.dat","r+"); gotoxy(3,24);printf(" "); gotoxy(6,4);printf(" list records "); gotoxy(1,5);printf("|-------------------------------------|"); gotoxy(41,4);printf(" "); gotoxy(41,5);printf(" |"); while(fscanf(fp,"%10s%14s%f\n",chtime,chshop,&chm)!=EOF) { if(i==36) { getch(); i=0; } if((i%36)《17) { gotoxy(4,6+i); printf(" "); gotoxy(4,6+i); } else if((i%36)》16) { gotoxy(41,4+i-17); printf(" "); gotoxy(42,4+i-17); } i++; sum=sum+chm; printf("%10s %-14s %6.1f\n",chtime,chshop,chm); } gotoxy(1,23);printf("|---------------------------------------------------------------------------|"); gotoxy(1,24);printf("| |"); gotoxy(1,25);printf("|---------------------------------------------------------------------------|"); gotoxy(10,24);printf("total is %8.1f$",sum); fclose(fp); gotoxy(49,24);printf("press any key to.....");getch();goto pp; } else { while(ch!=’\r’) { if(j《10) { strncat(chtime,ch,1); j++; } if(ch==8) { len=strlen(chtime)-1; if(j》15) {len=len+1; j=11;} strcpy(ch1,""); j=j-2; strncat(ch1,chtime,len); strcpy(chtime,""); strncat(chtime,ch1,len-1); gotoxy(13,7);printf(" "); } gotoxy(13,7);printf("%s",chtime);ch=getch(); if(ch==9) goto mm; if(ch==27) exit(1); } gotoxy(3,24);printf(" "); gotoxy(13,10); j=0; ch=getch(); while(ch!=’\r’) { if (j《14) { strncat(chshop,ch,1); j++; } if(ch==8) { len=strlen(chshop)-1; strcpy(ch1,""); j=j-2; strncat(ch1,chshop,len); strcpy(chshop,""); strncat(chshop,ch1,len-1); gotoxy(13,10);printf(" "); } gotoxy(13,10);printf("%s",chshop);ch=getch(); } gotoxy(13,13); j=0; ch=getch(); while(ch!=’\r’) { if (j《6) { strncat(chmoney,ch,1); j++; } if(ch==8) { len=strlen(chmoney)-1; strcpy(ch1,""); j=j-2; strncat(ch1,chmoney,len); strcpy(chmoney,""); strncat(chmoney,ch1,len-1); gotoxy(13,13);printf(" "); } gotoxy(13,13);printf("%s",chmoney);ch=getch(); } if((strlen(chshop)==0)||(strlen(chmoney)==0)) continue; if((fp=fopen("home.dat","a+"))!=NULL); fprintf(fp,"%10s%14s%6s",chtime,chshop,chmoney); fputc(’\n’,fp); fclose(fp); i++; gotoxy(41,5+i); printf("%10s %-14s %-6s",chtime,chshop,chmoney); } } getch();}

谁能帮我编一个C语言的小程序

//英尺feet 英寸inch 厘米centimeter#include《stdio.h》//英尺转换为英寸 1英尺=12英寸FeetToInch(float t){ float t1; t1=12*t; printf("%f英尺转换为英寸后是:%f英寸\n",t,t1);}//英寸转换为厘米 1英寸=2.54厘米InchToCentimeter(float t){ float t2; t2=2.54*t; printf("%f英寸转换为厘米后是:%f厘米\n",t,t2);}//厘米转换为米 100厘米=1米CentimeterToMeter(float t){ float t3; t3=t/100; printf("%f厘米转换为米后是:%f米\n",t,t3);}main(){ float tt; printf("输入需要转换的数字:\n"); scanf("%f",&tt); FeetToInch(tt); InchToCentimeter(tt); CentimeterToMeter(tt);}

关于c语言编程简单的小程序,给几个50行左右简单的C语言程序设计 谢谢~~的介绍到此结束,希望对大家有所帮助。

c语言编程简单的小程序(给几个50行左右简单的C语言程序设计  谢谢~~)

本文编辑:admin
Copyright © 2022 All Rights Reserved 威海上格软件有限公司 版权所有

鲁ICP备20007704号

Thanks for visiting my site.