//
#include "stdafx.h"
#include <iostream>
using namespace std
int prime(int x){
for(int i= 2i<x i++){
if(x%i == 0)
return 0
}
return 1
}
int _tmain(int argc, _TCHAR* argv[])
{
int m,k=0
int arr[2000]={0}
printf("输入50到2000之间的整数: ")
cfu:
scanf("%d",&m)
if (m >= 50 &&m <= 2000)
{
//判断在m以内有素数
for (int i =2i <mi++)
{
if (prime(i)==1){
printf("%d 是素数\n",i)
arr[k++]= i
}else{
printf("%d 不是素数\n",i)
}
}
}else{
printf("输入50到2000之间的整数")
goto cfu
}
cout <<"K的值: "<<k <<endl
for (int i = 0i <k-1i++)
{
for (int j = 0j <k-1-ij++)
{
if (arr[j] <arr[j+1] )
{
int temps = arr[j]
arr[j] = arr[j+1]
arr[j+1] = temps
}
}
}
printf("10个数排序:")
for (int i = 0i<ki++)
{
printf("%d ",arr[i])
}
while(1)
return 0
}
#include<iostream>using namespace std
int main(){
char c
int s=0,z=0,k=0,q=0
while((c=getchar())!='\n'){
int x=int(c)
if(x>=48&&x<=57)s++
else if((x>=65&&x<=90)||(x>=97&&x<=122))z++
else if(x=32)k++
else q++
}
cout<<"you have input "<<s<<" numbers"<<endl
cout<<"you have input "<<z<<" letters"<<endl
cout<<"you have input "<<k<<" spaces"<<endl
cout<<"you have input "<<q<<" some else chars"<<endl
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)