首页 > 其他分享 >实验2

实验2

时间:2023-03-22 23:02:34浏览次数:35  
标签:int TCHAR argv 实验 tmain printf include

task1

(1)line 18 代码实现的功能是 :一个586 到781 间的随机数

(2)该程序的功能为随机生成586到781 之间的"真·随机数"

task2

// .2.2.c.cpp : 定义控制台应用程序的入口点。
//

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


int _tmain(int argc, _TCHAR* argv[])
{
int a1, a2, a3;
char c1, c2, c3;
double x, y;


scanf(" %d %d %d\n", &a1, &a2, &a3);
getchar();
printf("a1 = %d, a2 = %d, a3 = %d\n",a1, a2, a3);
getchar();
scanf("%c %c %c\n",&c1, &c2, &c3);
getchar();
printf("c1 = %c, c2 = %c, c3 = %c\n",c1, c2, c3);


scanf(" %lf, %lf\n", &x, &y);
getchar();
printf("x = %lf, y = %lf\n", x, y);


system("pause");
return 0;
}

 

 

task3.1

// uuuuuu.cpp : 定义控制台应用程序的入口点。
//

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

int _tmain(int argc, _TCHAR* argv[])
{
    double x, ans;
    scanf_s("%lf", &x);
    ans = pow(x, 365);
    printf("%.2f的365次方:%.2f\n", x, ans);

    system("pause");
    return 0;
}

 

task3.2

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

int _tmain(int argc, _TCHAR* argv[])
{
    double x, ans;
    
    while(scanf_s("%lf", &x) != EOF)
    {
        ans = pow(x, 365);
    printf("%.2f的365次方:%.2f\n", x, ans);
    printf("\n");
    }

    system("pause");
    return 0;
}

task3.3

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

int _tmain(int argc, _TCHAR* argv[])
{
    double C, F;
    
    while(scanf_s("%lf", &C) != EOF)
    {
        F =( C*9/5 + 32);
    printf("摄氏度C = %.2f时,华氏度F = %.2f\n", C, F);
    printf("\n");
    }

    system("pause");
    return 0;
}

task4

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

int _tmain(int argc, _TCHAR* argv[])
{
    char s;
    
    while((s = getchar()) != EOF)
    {
        switch(s)
        {
            case 'y': printf("wait a minute\n");break;
            case 'g': printf("go go go\n");break;
            case 'r': printf("stop!\n");break;
            default :{ printf("somehing must be wrong...\n");}break;
        }
    printf("\n");
    }

    system("pause");
    return 0;
}

task5

#include "stdafx.h"
#include <stdlib.h>
#include <time.h>
#include <stdio.h>

int _tmain(int argc, _TCHAR* argv[])
{
    int a, b, i;
    srand( time(0));

    a = rand() % 30 + 1;
    printf("猜猜2023年四月哪一天会是你的lucky day\n");

    for(i=1;i=3;++i)
    {
        scanf("%d", &b);
        if(a = b){
           printf("哇,猜中了:-)\n");break;
        }
        else{
           if(a > b)
              printf("你猜的日期早了,你的lucky day还没到呢\n");
           else
              printf("你猜的日期晚了,你的lucky day已经过啦\n");
        }
    }
    if(a = b)
        getchar();
    else
        printf("次数用完啦,偷偷告诉你:四月你的lucky day是%d\n", a);

    system("pause");
    return 0;
}

task6

// uuuuuu.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <stdlib.h>
#include <time.h>
#include <stdio.h>

int _tmain(int argc, _TCHAR* argv[])
{
  int i, n;
  for(i=1;i<=9;i++){
      for(n=1;n<=i;n++)
          printf("%d x %d = %d ", n, i, n*i);
      printf("\n");
  }

    system("pause");
    return 0;
}

task7

// uuuuuu.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <stdlib.h>
#include <time.h>
#include <stdio.h>

int _tmain(int argc, _TCHAR* argv[])
{
     int i, n, a, t, v;
     scanf("%d", &a);
 
     for(i=a;i>=1;i--){
         t = (2*i - 1);
        for(v=a;v>i;v--)
             printf("        ");
        for(n=1;n<=t;n++)
             printf(" O  \t");
             printf("\n");
        for(v=a;v>i;v--)
             printf("        ");
        for(n=1;n<=t;n++)
             printf("<H> \t");
             printf("\n"); 
        for(v=a;v>i;v--)
             printf("        ");
        for(n=1;n<=t;n++)
             printf("I I \t");
         printf("\n");
      }

    system("pause");
    return 0;
}

 

标签:int,TCHAR,argv,实验,tmain,printf,include
From: https://www.cnblogs.com/sk04qi/p/17223592.html

相关文章

  • 实验2
    task1编程代码#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;s......
  • 实验二
    实验任务1源码#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;......
  • 实验二
    #include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;srand(time......
  • 实验2 字符串和列表
    一、实验结论:1、实验任务1:task1.py程序源码:1#字符串的基础操作2#课堂上没有演示的一些方法34x='nbaFIFA'5print(x.upper())#字符串转......
  • 实验2 字符串和列表
    任务1x='nbaFIFA'print(x.upper())print(x.lower())print(x.swapcase())print()x='abc'print(x.center(10,'*'))print(x.ljust(10,'*'))print(x.rjust(10,'*'......
  • 实验2
    2.1#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN6#defineR1586#defineR2701intmain(){intnumber;inti;srand(time(0));for(i=0;......
  • 实验2
    #include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;srand(ti......
  • 实验2
    实验任务1#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;......
  • 实验2 字符串与列表
    1x='nbaFIFA'2print(x.upper())3print(x.lower())4print(x.swapcase())5print()67x='abc'8print(x.center(10,'*'))9print(x.ljust(10,'*'))......
  • 实验2
    x='nbaFIFA'print(x.upper())print(x.lower())print(x.swapcase())print()x='abc'print(x.center(10,'*'))print(x.ljust(10,'*'))print(x.rjust(10,'*'))......