黑客24小时在线接单网站

黑客技术,黑客教程,网络黑客,渗透测试,破解软件

c语言基础编程100道(c语言基础编程100道带答案)

本文目录一览:

100分C语言编程题!一个半小时之内求答案,采纳追加50分!

第一题:

#include stdlib.h

#include stdio.h

#include conio.h

#define RMAX 3

#define cMAX 4

void sumRow(int a[][cMAX],int b[])

{

for(int i = 0;i RMAX;i++)

{

b[i] = 0;

for(int j = 0;j cMAX;j ++)

b[i] += a[i][j];

}

}

void main()

{

int i,j,a[RMAX][cMAX],b[RMAX];

clrscr();

randomize();

for(i=0;iRMAX;i++)

for(j=0;jcMAX;j++)

a[i][j]=random(nMAX);

printf("产生随机数后数组如下所示:\n");

for(i=0;iRMAX;i++){

for(j=0;jcMAX;j++)

printf("%d ",a[i][j]);

printf("\n");

}

sumRow(a,b);

printf("每行的和为:\n");

for(i=0;iRMAX;i++){

printf("第%d行和为%d\n",i+1,b[i]);

}

}

-----------------------------------------------

第二题

#include stdlib.h

#include stdio.h

void replace(char *p,char ch)

{

while(*p != '\0'){

if(*p == ch)*p='x';

p ++;

}

}

void main()

{

char str[] = "I am a student in hunan university";

printf("请输入字符:");

char ch = getchar();

replace(str,ch);

printf("替换后的字符串为:%s\n",str);

}

-------------------------------------------

第三题

#include stdlib.h

#include stdio.h

#include string.h

#define LEN 20

void sort(char str[][LEN],int n)

{

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

for(int j = 0;j n-1-i;j ++)

if(strcmp(str[j],str[j+1]) 0)

{

char s[LEN];

strcpy(s,str[j]);

strcpy(str[j],str[j+1]);

strcpy(str[j+1],s);

}

}

void main()

{

char str[][LEN] = {"student","worker","teacher","doctor"};

sort(str,4);

printf("排序后的字符串数组为:\n");

for(int i = 0;i 4;i ++)

printf("%s\n",str[i]);

}

c语言编程题

/*1,编写程序,把560分钟换算成用小时和分钟表示,然后进行输出。*/

/*#includestdio.h

main()

{

int a=560,b,c;

b=a/60;

c=a%60;

printf("把560分钟换算成用小时和分钟表示时为%d小时%d分钟\n",b,c);

}*/

/*2,编写程序,输入两个整数:1500和350,求出它们的商和余数进行输出。*/

/*#includestdio.h

main()

{

int a,b,c,d;

printf("请输入两个整数:");

scanf("%d%d",a,b);

c=a/b;

d=a%b;

printf("这两个数的商是%d,余数是%d",c,d);

}*/

/*3,编写程序,读入三个双精度数,求它们的平均值并保留此平均值小数点后一位数,

对小数点后第二位数进行四舍五入,最后输出结果。*/

/*#includestdio.h

main()

{

double a,b,c;

float aver;

long h;

printf("请输入三个双精度数:");

scanf("%lf%lf%lf",a,b,c);

aver=(a+b+c)/3.0;

h=(aver*100+5)/10;

aver=(float)h/10;

printf("对它们的平均值保留小数点后一位为:%f",aver);

}*/

/*4,编写程序,读入三个整数给a、b、c,然后交换它们中的数,把a中原来的值给b,

把b中原来的值给c,把c中原来的值给a,然后输出a、b、c。*/

#includestdio.h

main()

{

int a,b,c,temp1,temp2;

printf("请输入三个整数:");

scanf("%d%d%d",a,b,c);

temp1=b;

temp2=c;

b=a;

c=temp1;

a=temp2;

printf("交换后它们分别为%d\t%d\t%d\n",a,b,c);

}

简单C语言编程

1。#include iostream

using namespace std;

int main()

{

int i;

for(i=0;i=100;i++)

{

if(i%4==0i%9==0)

coutiendl;

}

return 0;

}

2。

#include iostream

using namespace std;

int main()

{int a,b,c,d;

cinabc;

d=c;

c=b;

b=a;

a=d;

coutaendlbendlcendl;

return 0;

}

3。#include fstream

#include iostream

using namespace std;

int main()

{

char a[90];

ofstream outfile("your_file.txt",ios::out);

cin.getline(a,90);

outfilea;

return 0;

}

4。

#include iostream

using namespace std;

int main()

{

char c[80];

cin.getline(c,80);

int i=0,j=0;

while(c[i]!='\0')

{

if(c[i]=65c[i]=90)

i++;

j++;

}

coutjendl;

return 0;

}

5。

#include iostream

using namespace std;

struct student

{

char name[50];

int score;

};

int main()

{

student a[5];

int i;

for(i=0;i=4;i++)

{

cina[i].namea[i].score;

}

FILE *fp;

fp=fopen("data1.txt","w");

for(i=0;i=4;i++)

{

fprintf(fp,"%s\n",a[i].name);

fprintf(fp,"%d\n",a[i].score);

}

fclose(fp);

return 0;

}

急求 几道C语言基础编程大题 求详细过程

/*九九乘法表*/

#include stdio.h

int main()

{

int i,j;

for(i=1;i10;i++)

{

for(j=1;j10;j++)

{

printf("%dX%d=%d\t",i,j,j*i);

if(i==j)

break;

}

printf("\n");

}

return 0;

}

  • 评论列表:
  •  竹祭酒废
     发布于 2022-07-30 01:23:13  回复该评论
  • tdlib.h#include stdio.h#include string.h#define LEN 20void sort(char str[][LEN],int n)

发表评论:

«    2025年4月    »
123456
78910111213
14151617181920
21222324252627
282930
文章归档
标签列表

Powered By

Copyright Your WebSite.Some Rights Reserved.