首页 > 其他分享 >实验

实验

时间:2023-03-04 19:47:24浏览次数:28  
标签:10 include return int 实验 printf main

test1.c

代码

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

结果

代码

#include<stdio.h>
#include<stdlib.h>

int main()
{
    printf("O\n");
    printf("<H>\n");
    printf("I I\n");

    printf("O\n");
    printf("<H>\n");
    printf("I I\n");
    
    system("pause");

    return 0;
}

 

结果

 

代码

#include<stdio.h>
#include<stdlib.h>

int main()
{
   printf(" O        O \n");
    printf("<H>      <H>\n");
    printf("I I      I I\n");
    
    
    system("pause");

    return 0;
}

 

结果

 

test2.c

代码

#include <stdio.h>

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

结果

3、4不符合题目要求

test3.c

代码

#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;
 } 

结果

test4.c

代码

#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;
    
    printf("t=%d\n",t);
    
    return 0;
}

结果

test5.c

代码

#include<stdio.h>
#include<stdlib.h>

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

    return 0;
}

 

结果

 

 

 test6.c

#include <stdio.h>
#include <stdlib.h>
int main()
{
    int year;
    
    year = 1e+009/(3600*24*365);
    
    printf("10亿秒约等于%d年\n", year);
    system("pause");
    return 0;
 } 

结果

test7.c

代码

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
    int n;
    int a;
    srand((unsigned)time(NULL));
    a = rand() % 41 + 60;
    n = a;

    printf("n = %d\n", n);

    system("pause");

    return 0;
}

结果

test8.c

代码

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main()
{
    char ans1, ans2;

    printf("每次课前认真预习、课后及时复习了没?(输入y或Y表示有,输入n或N表示没有): ");
    ans1 = getchar(); //从键盘输入一个字符,赋值给ans1

    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");

    system("pause");

    return 0;
}

结果

 

标签:10,include,return,int,实验,printf,main
From: https://www.cnblogs.com/chq5/p/17172746.html

相关文章

  • 实验1
    实验任务1实验代码#include<stdio.h>intmain(){ printf("00\n"); printf("<H><H>\n"); printf("IIII\n"); return0;}实验结论实验任......
  • GPIO与跑马灯实验
    STM32学习之GPIO实战:跑马灯库函数操作步骤使能IO口时钟。调用RCC_APB2PeriphClockCmd();初始化IO口模式,调用GPIO_Init();操作IO口,输出高低电平。GPIO_SetBits();GP......
  • 实验一
    实验任务1程序源码//打印一个字符小人#include<stdio.h>#include<stdlib.h>intmain(){printf("O\n");printf("<H>\n");printf("II\n");pr......
  • 实验1
    实验任务1task1代码:#include<stdio.h>intmain(){printf("O\n");printf("<H>\n");printf("II\n");return0;}运行结果:  t......
  • 实验一
    实验任务一程序源代码(task1.1.c)//打印一个字符小人#include<stdio.h>intmain(){printf("o\n");printf("<H>\n");printf("II\n");printf(......
  • 实验1 C语言开发环境使用和类型,运算符,表达式
    //打印一个字符小人#include<stdio.h>intmain(){ printf("O\n"); printf("<H>\n"); printf("II\n");printf("O\n");printf("<H>\n");printf("II\n"......
  • 实验一
    task1-1//垂直方向上打印两个字符小人#include<stdio.h>intmain(){printf("0\n");printf("<H>\n");printf("II\n");printf("0\n");......
  • 实验1
    TEST1实验代码#include<stdio.h>intmain(){ printf("OO\n"); printf("<H><H>\n"); printf("IIII\n"); getchar(); return0;}#include<stdio.h>intmain(......
  • 实验1
    task1代码://打印一个字符小人#include<stdio.h>#include<stdlib.h>intmain(){  printf("o\n");  printf("<H>\n");  printf("II\n");  system("p......
  • 实验一
    任务一#include<stdlib.h>#include<stdio.h>intmain(){ printf("0""0\n"); printf("<H>""<H>\n"); printf("II""II\n"); system("pause"); return0;}......