首页 > 其他分享 >实验一

实验一

时间:2023-03-03 23:44:06浏览次数:29  
标签:10 pause int system 实验 printf include

任务一
#include <stdlib.h> #include <stdio.h> int main() { printf(" 0"" 0\n"); printf("<H>""<H>\n"); printf("I I""I I\n"); system("pause"); return 0; }
#include <stdlib.h>
#include <stdio.h>
int main()
{
	printf(" 0\n");
	printf("<H>\n");
	printf("I I\n");
	
	system("pause");
	return 0;
}

  

任务二#include <stdlib.h>

#include <stdio.h>

int main()
{
	int n,sum;

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

  

第三个和第四个不行,因为如果n是奇数,在int类型下,除以二就会损失一部分数,,数会变小。

 

任务三

#include <stdlib.h>
#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);
        system("pause");
	return 0;
}

  

功能是将a和b的值互换

 

任务四

#include <stdlib.h>
#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);
	system("pause");
	return 0;
}

  

功能是实现个位数和百位数的互换

 任务五

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

  

任务六

#include <stdlib.h>
#include <stdio.h>
int main()
{
	int year;
	year=(int)(1e9/3600/24/365+0.5);

	printf("10亿秒等于%d年\n",year);
	system("pause");
	return 0;
}

  

任务七

#include <stdlib.h>
#include <stdio.h>
int main()
{
	int n;
	srand(time(0));
	n=60+rand()%41;
	printf("n=%d",n);
	
	system("pause");
	return 0;
}

  

 

任务八

#include <stdio.h>
int main()
{
	char ans1,ans2;

	printf("每次课前认真预习,及时复习了吗(输入y或者Y表示有,nN表示没有)");

	ans1=getchar();
	getchar();

	printf("\n手动敲代码了吗(输入y或者Y表示有,nN表示没有)");
	ans2=getchar();
	
	if(ans1=='y'||ans1=='Y' && ans2=='y'||ans2=='Y')
		printf("\n罗马不是一天建成的,继续保持\n");
	else
		printf("\n罗马不是一天毁灭的,快来建设吧\n");

	system("pause");
	return 0;
}

 

  

  

标签:10,pause,int,system,实验,printf,include
From: https://www.cnblogs.com/jiang4533/p/17172605.html

相关文章

  • 实验任务一
    实验任务1程序源码(1)//打印一个字符小人#include<stdio.h>#include<stdlib.h>intmain(){printf("O\n");printf("<H>\n");printf("II\n");......
  • 实验1
    实验任务1程序源码:#include<stdio.h>#include<stdlib.h>intmain(){ printf("O\n"); printf("<H>\n"); printf("II\n");system("pause"); return0;}......
  • 实验1
    task1程序源码(task1-1)//打印一个字符小人#include<stdio.h>intmain(){printf("o\n");printf("<H>\n");printf("II\n");return0......
  • 实验任务1
    实验任务1//打印一个字符小人#include<stdio.h>intmain(){printf("oo\n");printf("<H><H>\n");printf("IIII\n");return0;......
  • 实验一
    实验任务一程序源代码//打印一个字符小人#include<stdio.h>intmain(){printf("o\n");printf("<H>\n");printf("II\n");printf("o\n"......
  • 实验一
    task1程序源码#include<stdio.h>#include<stdlib.h>intmain(){ printf("o\n"); printf("<H>\n"); printf("II\n"); system("pause"); return0;}图片......
  • 实验一 20230302
    #include<stdio.h>intmain(){printf("0\n");printf("<H>\n");printf("II\n");return0;} #include<stdio.h>intmai......
  • 实验1
    实验内容1#include<stdio.h>intmain(){printf("o\n");printf("<H>\n");printf("II\n");printf("o\n");printf("<H>\n");......
  • 火山引擎 DataTester:A/B 实验如何实现人群智能化定向?
    更多技术交流、求职机会,欢迎关注字节跳动数据平台微信公众号,回复【1】进入官方交流群在精细化运营时代,用户需求和业务场景愈加多元,在产品功能迭代以及各类活动中,面向不......
  • c实验1
      实验任务1//打印一个字符小人#include<stdio.h>intmain(){printf("O\n");printf("<H>\n");printf("II\n");return0;}......