如何在Linux中使用Vi来创建一个C源程序文件?

如何在Linux中使用Vi来创建一个C源程序文件?,第1张

~#vi tmp.c\x0d\x0a按i进入插入模式,输入源文件内容\x0d\x0a#include \x0d\x0aint main(int argc,char *argv[])\x0d\x0a{\x0d\x0a printf("just a case!\r\n")\x0d\x0a return(0)\x0d\x0a}\x0d\x0a按ESC退出插入模式,输入\x0d\x0a:wq\x0d\x0a回到shell\x0d\x0a~#gcc tmp.c\x0d\x0a~#./a.out

1)

#include<stdio.h>

void main()

{

int i,j

scanf("%d,%d",&i,&j)

printf("%d",i>j?i:j)

}

2)

#include <math.h>

#include <stdio.h>

main( )

{

float a,b,c,s,x1,x2

double t

printf(" please input a,b,c:")

scanf("%f %f %f" , &a , &b , &c)

if (a==0.0)

if(b != 0.0)

printf("the root is :%f\n",-c/b)

else if (c==0.0)

printf("x is inexactive\n ")

else

printf("no root!\n")

else

{

s = b * b - 4 * a * c

if(s >= 0.0)

if(s >0.0)

{

t = sqrt( s )

x1 = -0.5 *(b + t) / a

x 2 = - 0.5 * ( b - t ) / a

printf("There are two different roots:%f and%f\n" ,x 1 , x 2 )

}

else

printf("There are two equal roots:%f\n",-0.5*b/a)

else

{

t = sqrt( -s )

x1=-0.5*b/a/ *实部* /

x2=abs(0.5*t/a)/*虚部的绝对值* /

printf("There are two virtual roots:")

printf("%f+i%f\t\t%f-i%f\n",x1,x2,x1,x2 )

}

}

}

您好,以下是用vim编写C语言指一个三位正整数的数组的步骤:

打开终端,输入vim命令,进入vim编辑器

输入以下代码:

#include <stdio.h>

int main(){  

int arr[3] 

return 0

}

保存文件并退出vim编辑器

希望这能帮到您。如果您有其他问题,请随时问我。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/12089381.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-20
下一篇 2023-05-20

发表评论

登录后才能评论

评论列表(0条)

保存