首页 > 其他分享 >实验1

实验1

时间:2023-03-03 13:13:39浏览次数:39  
标签:main return int ans1 实验 printf include

#include <stdio.h>

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

    return 0;
}

task1

#include <stdio.h>>

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

task2

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

task3

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

task4

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

task5

#include <stdio.h>>
int main()
{
   int year;
   
   year = 10000000000/365/24/60/60;
   
   printf("10亿年约等于%d年\n",year);
   
   return 0;
}

task6

 

#include <stdio.h>
#include <stdlib.h>
int main()

 

{
    int n;
    n = rand()%100+59;
    printf("n = %d\n",n);
    system("pause");

    return 0;
}

task7

#include <stdio.h>
#include <stdlib.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");

    system("pause");

    return 0;
}

task8

总结:好。

标签:main,return,int,ans1,实验,printf,include
From: https://www.cnblogs.com/nbb233/p/17172735.html

相关文章

  • 实验1
    实验任务1task1-1#include<stdio.h>intmain(){printf("o\n");printf("<H>\n");printf("II\n");printf("o\n");printf("<H>\n");......
  • 实验1
    实验任务1代码1#include<stdio.h>2intmain()3{4printf("oo\n");5printf("<H><H>\n");6printf("IIII\n");78return0;......
  • 实验1
    【实验任务1】源码1_1://打印一个字符小人#include<stdio.h>#include<stdlib.h>intmain(){ printf("o\n"); printf("<H>\n"); printf("II\n"); printf("o\n"......
  • 实验1
    实验任务1程序代码:#include<stdio.h>#include<stdlib.h>intmain(){printf("0\n");printf("<H>\n");printf("II\n");system("pause");......
  • 实验1
    1.实验任务1垂直方向上#include<stdio.h>#include<stdlib.h>intmain(){ printf(" O\n"); printf("<H>\n"); printf(" II\n");printf(" O\n");printf("<H>......
  • 实验1
    1.实验任务1task1_1.c#include<stdio.h>#include<stdlib.h>intmain(){printf("0\n");printf("<H>\n");printf("II\n");printf("0\n");......
  • 实验一
    实验任务一源代码//打印垂直两个字符小人#include<stdio.h>intmain(){printf("o\n");printf("<h>\n");printf("II\n");printf("o\n");......
  • 实验1
    //打印一个字符小人#include<stdio.h>intmain(){printf("o\n");printf("<H>\n");printf("II\n");return0;}//1+2+3+...+n(设n......
  • 实验任务
    /*task1.c*/1#include<stdio.h>2intmain()3{45printf("o\n");6printf("<H>\n");7printf("II\n");89return0;10}/......
  • 实验1
    实验任务1-1运行结果 程序源码#include<stdio.h>intmain(){printf("o\n");printf("<H>\n");printf("II\n");printf("o\n");printf(......