-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
966 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
int main() { | ||
int n; scanf("%d", &n); | ||
string s; | ||
while(n){ | ||
s+='0'+(n%2); | ||
n/=2; | ||
} | ||
reverse(s.begin(), s.end()); | ||
cout << s << endl; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
[Project] | ||
FileName=13-1.dev | ||
Name=13-1 | ||
Type=1 | ||
Ver=2 | ||
ObjFiles= | ||
Includes= | ||
Libs= | ||
PrivateResource= | ||
ResourceIncludes= | ||
MakeIncludes= | ||
Compiler= | ||
CppCompiler= | ||
Linker= | ||
IsCpp=1 | ||
Icon= | ||
ExeOutput= | ||
ObjectOutput= | ||
LogOutput= | ||
LogOutputEnabled=0 | ||
OverrideOutput=0 | ||
OverrideOutputName= | ||
HostApplication= | ||
Folders= | ||
CommandLine= | ||
UseCustomMakefile=0 | ||
CustomMakefile= | ||
IncludeVersionInfo=0 | ||
SupportXPThemes=0 | ||
CompilerSet=0 | ||
CompilerSettings=0000000000000000000000000 | ||
UnitCount=1 | ||
|
||
[VersionInfo] | ||
Major=1 | ||
Minor=0 | ||
Release=0 | ||
Build=0 | ||
LanguageID=1033 | ||
CharsetID=1252 | ||
CompanyName= | ||
FileVersion= | ||
FileDescription=Developed using the Dev-C++ IDE | ||
InternalName= | ||
LegalCopyright= | ||
LegalTrademarks= | ||
OriginalFilename= | ||
ProductName= | ||
ProductVersion= | ||
AutoIncBuildNr=0 | ||
SyncProduct=1 | ||
|
||
[Unit1] | ||
FileName=main.cpp | ||
CompileCpp=1 | ||
Folder= | ||
Compile=1 | ||
Link=1 | ||
Priority=1000 | ||
OverrideBuildCmd=0 | ||
BuildCmd= | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Project: 13-1 | ||
# Makefile created by Dev-C++ 5.2.0.3 | ||
|
||
CPP = g++.exe -D_DEBUG_ | ||
CC = gcc.exe -D_DEBUG_ | ||
WINDRES = windres.exe | ||
OBJ = main.o $(RES) | ||
LINKOBJ = main.o $(RES) | ||
LIBS = -L"E:/Ѹ������/DevCpp/Dev-Cpp/MinGW32/lib" -static-libstdc++ -static-libgcc | ||
INCS = -I"E:/Ѹ������/DevCpp/Dev-Cpp/MinGW32/include" | ||
CXXINCS = -I"E:/Ѹ������/DevCpp/Dev-Cpp/MinGW32/include" | ||
BIN = 13-1.exe | ||
CXXFLAGS = $(CXXINCS) -g3 | ||
CFLAGS = $(INCS) -g3 | ||
RM = rm -f | ||
|
||
.PHONY: all all-before all-after clean clean-custom | ||
|
||
all: all-before 13-1.exe all-after | ||
|
||
|
||
clean: clean-custom | ||
${RM} $(OBJ) $(BIN) | ||
|
||
$(BIN): $(OBJ) | ||
$(CPP) $(LINKOBJ) -o "13-1.exe" $(LIBS) | ||
|
||
main.o: main.cpp | ||
$(CPP) -c main.cpp -o main.o $(CXXFLAGS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <iostream> | ||
#include<stack> | ||
using namespace std; | ||
/*1、输入任意一个十进制整数,转换为二进制数串显示出来。*/ | ||
int main() { | ||
stack<int> s; //建栈 | ||
int n; | ||
cin>>n; //输入一个十进制数 | ||
while(n!=0){ | ||
s.push(n%2); //将余数存入栈中 | ||
n/=2; | ||
} | ||
while(s.empty()!=true){ | ||
cout<<s.top(); //输出栈顶元素 | ||
s.pop(); //将栈顶元素弹出 | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
[Project] | ||
FileName=13-2.dev | ||
Name=13-2 | ||
Type=1 | ||
Ver=2 | ||
ObjFiles= | ||
Includes= | ||
Libs= | ||
PrivateResource= | ||
ResourceIncludes= | ||
MakeIncludes= | ||
Compiler= | ||
CppCompiler= | ||
Linker= | ||
IsCpp=1 | ||
Icon= | ||
ExeOutput= | ||
ObjectOutput= | ||
LogOutput= | ||
LogOutputEnabled=0 | ||
OverrideOutput=0 | ||
OverrideOutputName= | ||
HostApplication= | ||
Folders= | ||
CommandLine= | ||
UseCustomMakefile=0 | ||
CustomMakefile= | ||
IncludeVersionInfo=0 | ||
SupportXPThemes=0 | ||
CompilerSet=0 | ||
CompilerSettings=0000000000000000000000000 | ||
UnitCount=1 | ||
|
||
[VersionInfo] | ||
Major=1 | ||
Minor=0 | ||
Release=0 | ||
Build=0 | ||
LanguageID=1033 | ||
CharsetID=1252 | ||
CompanyName= | ||
FileVersion= | ||
FileDescription=Developed using the Dev-C++ IDE | ||
InternalName= | ||
LegalCopyright= | ||
LegalTrademarks= | ||
OriginalFilename= | ||
ProductName= | ||
ProductVersion= | ||
AutoIncBuildNr=0 | ||
SyncProduct=1 | ||
|
||
[Unit1] | ||
FileName=main.cpp | ||
CompileCpp=1 | ||
Folder= | ||
Compile=1 | ||
Link=1 | ||
Priority=1000 | ||
OverrideBuildCmd=0 | ||
BuildCmd= | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Project: 13-2 | ||
# Makefile created by Dev-C++ 5.2.0.3 | ||
|
||
CPP = g++.exe -D_DEBUG_ | ||
CC = gcc.exe -D_DEBUG_ | ||
WINDRES = windres.exe | ||
OBJ = main.o $(RES) | ||
LINKOBJ = main.o $(RES) | ||
LIBS = -L"E:/Ѹ������/DevCpp/Dev-Cpp/MinGW32/lib" -static-libstdc++ -static-libgcc | ||
INCS = -I"E:/Ѹ������/DevCpp/Dev-Cpp/MinGW32/include" | ||
CXXINCS = -I"E:/Ѹ������/DevCpp/Dev-Cpp/MinGW32/include" | ||
BIN = 13-2.exe | ||
CXXFLAGS = $(CXXINCS) -g3 | ||
CFLAGS = $(INCS) -g3 | ||
RM = rm -f | ||
|
||
.PHONY: all all-before all-after clean clean-custom | ||
|
||
all: all-before 13-2.exe all-after | ||
|
||
|
||
clean: clean-custom | ||
${RM} $(OBJ) $(BIN) | ||
|
||
$(BIN): $(OBJ) | ||
$(CPP) $(LINKOBJ) -o "13-2.exe" $(LIBS) | ||
|
||
main.o: main.cpp | ||
$(CPP) -c main.cpp -o main.o $(CXXFLAGS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <iostream> | ||
#include<math.h> | ||
using namespace std; | ||
/*2、设想一下,32位整数int能表示最大多大数的阶乘。 | ||
假设y=x!(阶乘),在32位整数范围内,x最大为多少,y能达到最大值,而能保证乘法不溢出。 */ | ||
|
||
int main() { | ||
int sum=1,i; | ||
int temp; | ||
for (i=2;;i++) | ||
{ | ||
temp=sum*i; //i的阶乘 | ||
if (temp/sum!=i) //如果溢出了就跳出循环 | ||
break; | ||
sum=temp; | ||
} | ||
cout<<i-1<<"!="<<sum<<endl; //输出能达到的阶乘的最大值的数 | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
[Project] | ||
FileName=13-3.dev | ||
Name=13-4 | ||
Type=1 | ||
Ver=2 | ||
ObjFiles= | ||
Includes= | ||
Libs= | ||
PrivateResource= | ||
ResourceIncludes= | ||
MakeIncludes= | ||
Compiler= | ||
CppCompiler= | ||
Linker= | ||
IsCpp=1 | ||
Icon= | ||
ExeOutput= | ||
ObjectOutput= | ||
LogOutput= | ||
LogOutputEnabled=0 | ||
OverrideOutput=0 | ||
OverrideOutputName= | ||
HostApplication= | ||
Folders= | ||
CommandLine= | ||
UseCustomMakefile=0 | ||
CustomMakefile= | ||
IncludeVersionInfo=0 | ||
SupportXPThemes=0 | ||
CompilerSet=0 | ||
CompilerSettings=0000000000000000000000000 | ||
UnitCount=1 | ||
|
||
[VersionInfo] | ||
Major=1 | ||
Minor=0 | ||
Release=0 | ||
Build=0 | ||
LanguageID=1033 | ||
CharsetID=1252 | ||
CompanyName= | ||
FileVersion= | ||
FileDescription=Developed using the Dev-C++ IDE | ||
InternalName= | ||
LegalCopyright= | ||
LegalTrademarks= | ||
OriginalFilename= | ||
ProductName= | ||
ProductVersion= | ||
AutoIncBuildNr=0 | ||
SyncProduct=1 | ||
|
||
[Unit1] | ||
FileName=main.cpp | ||
CompileCpp=1 | ||
Folder= | ||
Compile=1 | ||
Link=1 | ||
Priority=1000 | ||
OverrideBuildCmd=0 | ||
BuildCmd= | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Project: 13-4 | ||
# Makefile created by Dev-C++ 5.2.0.3 | ||
|
||
CPP = g++.exe -D_DEBUG_ | ||
CC = gcc.exe -D_DEBUG_ | ||
WINDRES = windres.exe | ||
OBJ = main.o $(RES) | ||
LINKOBJ = main.o $(RES) | ||
LIBS = -L"E:/Ѹ������/DevCpp/Dev-Cpp/MinGW32/lib" -static-libstdc++ -static-libgcc | ||
INCS = -I"E:/Ѹ������/DevCpp/Dev-Cpp/MinGW32/include" | ||
CXXINCS = -I"E:/Ѹ������/DevCpp/Dev-Cpp/MinGW32/include" | ||
BIN = 13-3.exe | ||
CXXFLAGS = $(CXXINCS) -g3 | ||
CFLAGS = $(INCS) -g3 | ||
RM = rm -f | ||
|
||
.PHONY: all all-before all-after clean clean-custom | ||
|
||
all: all-before 13-3.exe all-after | ||
|
||
|
||
clean: clean-custom | ||
${RM} $(OBJ) $(BIN) | ||
|
||
$(BIN): $(OBJ) | ||
$(CPP) $(LINKOBJ) -o "13-3.exe" $(LIBS) | ||
|
||
main.o: main.cpp | ||
$(CPP) -c main.cpp -o main.o $(CXXFLAGS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <iostream> | ||
#include<string> | ||
using namespace std; | ||
/*3、 编程输入一个信用卡号码,输出合法性校验结果。Luhn算法可校验信用卡号码的合法性, | ||
信用卡号码只能由0-9的数字组成,通常16-19位长。 | ||
(1) 从卡号最后一位数字开始逆向将奇数位(1、3、5等)相加。 | ||
(2) 从卡号最后一位数字开始,逆向将偶数位数字,先乘以2(如果乘积为两位数,则将其减去9),再求和。 | ||
(3) 将奇数位总和加上偶数位总和,结果应能被10整除。 | ||
例如:5432123456788881合法。你若输错一位就不合法。 | ||
*/ | ||
|
||
int main() { | ||
string s; | ||
int sum1=0,sum2=0,sum=0; //sum1为奇数位和,sum2为偶数位数字乘2相加的和,sum为总和 | ||
int t=0; | ||
cin>>s; | ||
if(s.length()>=16&&s.length()<=19){ | ||
for(int i=s.length()-1;i>=0;i--){ | ||
if(t%2!=0){ //奇数位相加 | ||
sum1+=(s[i]-'0'); | ||
}if(t%2==0){ //偶数位相加 | ||
if((s[i]-'0')*2>=10) //若乘积为两位数,则将其减去9再相加 | ||
sum2=sum2+((s[i]-'0')*2-9); | ||
else | ||
sum2+=(s[i]-'0'); | ||
} | ||
t++; | ||
//cout<<"t="<<t<<" ";//调试可用 | ||
} | ||
sum=sum1+sum2; | ||
//cout<<"sum1="<<sum1<<";sum2="<<sum2<<endl;//调试可用 | ||
if(sum%10==0){ //能被10整除 | ||
//cout<<sum<<endl; | ||
cout<<"信用卡号码合法"; | ||
}else{ | ||
//cout<<sum<<endl; | ||
cout<<"信用卡号码不合法"; | ||
} | ||
}else{ | ||
cout<<"信用卡号长度不合法!!"; | ||
} | ||
return 0; | ||
} |
Oops, something went wrong.