@[TOC]王道OJ代码第一天
WEEK1DAY1
#define _CRT_SECURE_NO_WARNINGS 1
#pragma region quote
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#pragma endregion
#pragma region week1day1
int main()
{
printf("hello wangdao\n");
system("pause");
return 0;
}
#pragma endregion
WEEK1DAY2
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#pragma region week1day2
int main()
{
int a = 0, b = 0;
scanf("%d%d", &a, &b);
printf("%d", a + b);
return 0;
}
#pragma endregion
WEEK1DAY3
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#pragma region week1day3
int main()
{
int Num = 0;
scanf("%d", &Num);
if (Num < 65 || Num>122)
return 0;
else
{
printf("%c", Num);
return 0;
}
}
#pragma endregion
WEEK2DAY4
#define _CRT_SECURE_NO_WARNINGS 1
#pragma region quote
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#pragma endregion
#pragma region week2day4
int main()
{
int year = 0;
scanf("%d", &year);
if (year == 0)
printf("no");
else if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
printf("yes");
else
printf("no");
return 0;
}
#pragma endregion
WEEK2DAY5
#define _CRT_SECURE_NO_WARNINGS 1
#pragma region quote
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#pragma endregion
#pragma region week2day5
int main()
{
int a = 0;
char b = 0;
float c = 0.0;
scanf("%d %c %f", &a, &b, &c);
printf("%.2f", a + (int)b + c);
return 0;
}
#pragma endregion
WEEK2DAY6
#define _CRT_SECURE_NO_WARNINGS 1
#pragma region quote
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#pragma endregion
#pragma region week2day6
int main()
{
int a = 0;
scanf("%d", &a);
if (a < 10)
printf("no");
else
{
int num = 0, num1 = 0,temp=a;
while (temp)
{
num = temp % 10;
num1 = num1 * 10 + num;
temp = temp / 10;
}
if (a == num1)
printf("yes");
else printf("no");
return 0;
}
}
#pragma endregion
WEEK3DAY7WORK1
#define _CRT_SECURE_NO_WARNINGS 1
#pragma region quote
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#pragma endregion
#pragma region week3day7work1
int main()
{
int Num = 0,Sum=0;
scanf("%d", &Num);
if (Num == 0)
{
printf("1");
return 0;
}
else
{
Sum = Num;
while (Num != 0)
{
if (Num == 1)
break;
Sum = Sum * (Num - 1);
Num--;
}
printf("%d",Sum);
return 0;
}
}
#pragma endregion
WEEK3DAY7WORK2
#define _CRT_SECURE_NO_WARNINGS 1
#pragma region quote
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#pragma endregion
#pragma region week3day7work2
int main()
{
int Oneyuan = 1, Twoyuan = 1, Fiveyuan = 1, Tenyuan = 1,method=0;
for (Tenyuan=1; Tenyuan <= 40; Tenyuan++)
{
for (Twoyuan=1 ; Twoyuan <= 40;Twoyuan ++)
{
for (Fiveyuan=1; Fiveyuan <= 40; Fiveyuan++)
{
for (Oneyuan=1; Oneyuan <= 40; Oneyuan++)
{
if ((Oneyuan * 1 + Twoyuan * 2 + Fiveyuan * 5 + Tenyuan * 10 == 100)&&( Oneyuan + Twoyuan + Fiveyuan + Tenyuan == 40))
{
method++;
}
}
}
}
}
printf("%d", method);
}
#pragma endregion
WEEK3DAY8
#define _CRT_SECURE_NO_WARNINGS 1
#pragma region quote
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#pragma endregion
#pragma region week3day8
int main()
{
int BitNum = 0,flag=0;
scanf("%d", &BitNum);
if (BitNum == 0)
return 0;
int Num[100];
for (int x = 0; x<BitNum; x++)
{
scanf("%d", &Num[x]);
if (Num[x] == 2)
flag++;
}
printf("%d", flag);
}
#pragma endregion
WEEK3DAY9
#define _CRT_SECURE_NO_WARNINGS 1
#pragma region quote
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#pragma endregion
#pragma region week3day9
int main()
{
char string[100];
gets_s(string, 100);
int i = 0;
for (i = 0; string[i] != 0; i++);
i--;
if (string[i] != string[0])
{
if (string[i] > string[0])
printf("-1");
else
{
printf("1");
}
}
else
{
int flag = 0;
for (int x = i; x >= i + 1 / 2; x--)
{
if (string[x] != string[flag])
{
if (string[x] > string[flag])
{
printf("-1");
return 0;
}
if (string[x] < string[flag])
{
printf("1");
return 0;
}
}
flag++;
}
printf("0");
return 0;
}
}
#pragma endregion
WEEK4DAY10
#define _CRT_SECURE_NO_WARNINGS 1
#pragma region quote
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#pragma endregion
#pragma region week4day10
int main()
{
int i = 0;
scanf("%d", &i);
i = change(i);
printf("%d", i);
}
int change(int num)
{
num = num / 2;
return num;
}
#pragma endregion
WEEK4DAY11
#define _CRT_SECURE_NO_WARNINGS 1
#pragma region quote
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#pragma endregion
#pragma region week4day11
int main()
{
int i = 0;
char c;
scanf("%d", &i);
char* p = malloc(i);
scanf("%c", &c);
gets_s(p, i);
printf("%s", p);
return 0;
}
#pragma endregion
WEEK4DAY12
#define _CRT_SECURE_NO_WARNINGS 1
#pragma region quote
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#pragma endregion
#pragma region week4day12
int fun(int n)
{
if (n == 1)
{
return 1;
}
if (n == 2)
{
return 2;
}
else
{
return fun(n - 1) + fun(n - 2);
}
}
int main()
{
int n;
scanf("%d", &n);
printf("%d", fun(n));
return 0;
}
#pragma endregion
MIDDAY1
#define _CRT_SECURE_NO_WARNINGS 1
#pragma region quote
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#pragma endregion
#pragma region midday1
struct student
{
int number;
char name[10];
char sex[2];
};
int main()
{
struct student str1; char temp;
scanf("%d", &str1.number);
scanf("%c", &temp);
scanf("%s", &str1.name);
scanf("%c", &temp);
scanf("%s", str1.sex);
printf("%d %s %s", str1.number, str1.name, str1.sex);
}
#pragma endregion
MIDDAY2
#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<malloc.h>
using namespace std;
void fun(char*&p)
{
p = (char*)malloc(100);
fgets(p, 100, stdin);
}
int main()
{
char *p;
fun(p);
puts(p);
return 0;
}
所有内容均为本人学习记录,不得商用,侵权必删
|