首页 > 其他分享 >实验一

实验一

时间:2023-03-05 21:13:08浏览次数:132  
标签:10 程序运行 int 源码 实验 printf include

实验任务1

task1-1.c

程序源码

#include <stdio.h>
int main()
{
    printf("o\n");
    printf("<H>\n");
    printf("I I\n");
    printf("o\n");
    printf("<H>\n");
    printf("I I\n");
    
    return 0;
 } 

 

程序运行截图

task1-2.c

程序源码

#include <stdio.h>
int main()
{
    printf(" o   o\n");
    printf("<H> <H>\n");
    printf("I I I I\n");
    
    return 0;
    
}

 

程序运行截图

 

实验任务2

程序源码

#include<stdio.h> 

int main()
{
    int n,sum;
    
    
    scanf("%d",&n);
    sum = n*(n+1)/2;
    
    
    printf("sum=%d\n",sum);
}

程序运行截图

结论 写法3 4

       公式错误

实验任务3

程序源码

#include <stdio.h>

int main()
{
    int a,b,t;
    
    a=3;
    b=4;
    printf("a=%d,b=%d\n",a,b);
    
    t=a;
    a=b;
    b=t;
    printf("a=%d,b=%d\n",a,b);
    
    return 0;
 } 

程序运行截图

结论 循环赋值

实验任务四

程序源码

#include <stdio.h>

int main()
{
    int x,t,m;
    
    x=123;
    printf("x = %d\n",x);
    
    t=0;
    
    m=x%10;
    t=t*10+m;
    x=x/10;
    
    m=x%10;
    t=t*10+m;
    x=x/10;
    
    m=x%10;
    t=t*10+m;
    x=x/10;
    
    printf("t=%d\n",t);
    
    return 0;
 } 

程序运行截图

结论

实验五

程序源码

#include <stdio.h>

int main()
{
    float a,b,c;
    
    scanf("%f%f%f",&a,&b,&c);
    
    
    
    if((a+b>c&&b+c>a&&c+a>b))
    printf("能构成三角形\n");
    else
    printf("不能构成三角形\n");
    
    return 0;
}

程序运行截图

实验六

程序源码

#include <stdio.h>

int main()
{
    int year;
    
    year=10*10*10*10*10*10*10*10*10/(365*24*60*60);
    printf("10亿秒约等于%d年\n",year);
    return 0;
}
 

程序运行截图

实验七

程序源码

#include <stdio.h>
#include <stdlib.h>
int main()
{
    int n;
    n=rand()%(100-60+1)+60;
    printf("%d",n);
    return 0;
    
 } 

程序运行截图

 

实验八

程序源码

#include <stdio.h> 
int main()
{
    char ans1,ans2;
    
    printf("每次课前认真预习,课后认真复习了没?(输入y或Y表示有,输入n或N表示没有):");
    ans1 =getchar();
    
    getchar();
    
    printf("\n动手敲代码实践了没?(输入y或Y表示敲了,输入n或N表示没有敲);");
    ans2 = getchar();
    
    if (ans1 == 'Y'||ans1 =='y' && ans2 =='Y'||ans2=='y')
    printf("\n罗马不是一天建成的,继续保持哦:)\n");
    else
    printf("\n罗马不是一天毁灭的,我们来建设吧\n");
    
    return 0; 
    
 
 } 

程序运行截图

 

标签:10,程序运行,int,源码,实验,printf,include
From: https://www.cnblogs.com/202283300588t/p/17172789.html

相关文章

  • 实验1
    实验任务1源码:#include<stdio.h>#include<stdlib.h>intmain(){printf("O\n");printf("<H>\n");printf("II\n");system("pause");retur......
  • 实验1 C语言开发环境使用和编程初体验
    text1 程序源码//打印一个字符小人#include<stdio.h>intmain(){printf("o\n"); printf("<H>\n"); printf("II\n"); printf("o\n"); pri......
  • 实验一
      #include<stdio.h>#include<stdlib.h>intmain(){printf("o\n");printf("<H>\n");printf("II\n");printf("o\n");printf("<......
  • 实验一
    实验任务一编译截图:  编译码://打印一个字符小人#include<stdio.h>#include<stdlib.h>intmain(){printf("OO\n");printf("<H><H>\n");printf("IIII\n......
  • 实验一
    实验一源码://打印一个字符小人#include<stdio.h>#include<stdlib.h>intmain(){ printf("O\n"); printf("<H>\n"); printf("II\n"); system("pause"); return0;}......
  • 实验任务1
    #include<stdio.h>intmain(){printf("o\n");printf("<H>\n");printf("II\n");printf("o\n");printf("<H>\n");printf("II\n");......
  • 实验一:逆向软件设计和开发能力
    参考代码来源:https://blog.csdn.net/aasd23/article/details/123722532为完成实验目标,本人在网络上找到了一个基于jsp实现简单登录注册功能的程序,该项目功能基本完善,界面......
  • K8S CKA 1.26 模拟环境 实验环境(一键导入) Kubernetest v1.26题库
    K8SCKA1.26考试环境,按照CKA最新原题搭建的,模拟环境已集成考题,可直接模拟练习,做题实操。资料包含:2023年3月最新题库+答案解析+考试笔记+模拟环境+技术支持+在线辅导答疑......
  • Momiria:基于计算机程序模拟的疫情传播实验
    基于计算机程序模拟的疫情传播实验 Momiria​摘要:通过设计计算机程序模拟疫情传播机理,通过调控参数进行对比试验、并对实验数据进行函数拟合、数学建模,由此总结出......
  • 实验1
    #include<stdio.h>intmain(){printf("O\n");printf("<H>\n");printf("II\n");return0;}#include<stdio.h>intmain(){prin......