PDA

View Full Version : تبدیل حروف کوچک به بزرگ - مشکل این کد من چیه لطفا کمکم کنید



hentjanson
سه شنبه 19 مهر 1390, 21:04 عصر
// sample3.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <conio.h>
#include <iostream>
#include <string.h>
using namespace std;



int _tmain(int argc, _TCHAR* argv[])
{
int i;
char str[11];
cout<<"enter a name=";
cin.getline(str,11);
for (i=0 ; str[i]!=NULL ; i++)

if(str[i]=>'a' && str[i]<='z')
str[i]-=32
cout<<str;

getch();

return 0;
}

hentjanson
سه شنبه 19 مهر 1390, 21:05 عصر
// sample3.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <conio.h>
#include <iostream>
#include <string.h>
using namespace std;



int _tmain(int argc, _TCHAR* argv[])
{
int i;
char str[11];
cout<<"enter a name=";
cin.getline(str,11);
for (i=0 ; str[i]!=NULL ; i++)

if(str[i]=>'a' && str[i]<='z')
str[i]-=32
cout<<str;

getch();

return 0;
}

S.Reza
سه شنبه 19 مهر 1390, 21:18 عصر
int main()
{
int i;
char str[11];
clrscr();
cout<<"enter a name=";
cin.getline(str,11);
for (i=0 ; str[i]!=NULL ; i++)

if(str[i]>='a' && str[i]<='z')
str[i]-=32;
cout<<str;

getch();

return 0;
}

hentjanson
سه شنبه 19 مهر 1390, 21:25 عصر
بازم کار نکرد یعنی مقدار حالا میگیره ولی تبدیل نمیکنه مشکل از چیه ؟
#include "stdafx.h"
#include <conio.h>
#include <iostream>
#include <string.h>
using namespace std;



int _tmain(int argc, _TCHAR* argv[])
{
int i;
char str[11];
clrscr();
cout<<"enter a name=";
cin.getline(str,11);
for (i=0 ; str[i]!=NULL ; i++)

if(str[i]>='a' && str[i]<='z')
str[i]-=32;
cout<<str;

getch();

return 0;
}

m.soleimani
چهارشنبه 20 مهر 1390, 00:14 صبح
این به خوبی کار می‌کنه :



#include <conio.h>
#include <iostream>
#include <string.h>
using namespace std;
 
 
int main()
{
int i;
char str[11];
system("cls | color a");
cout<<"Enter a name: ";
cin.getline(str,11);
for (i=0 ; str[i]!=NULL ; i++)
if(str[i]>='a' && str[i]<='z')
str[i]-=32;
cout<<str;
_getch();
return 0;
}

amin4d
سه شنبه 17 اردیبهشت 1392, 17:18 عصر
کد بالا با یه کم تصحیح میتونه هر دو کارو با هم انجام بده:

#include <conio.h>
#include <iostream>
#include <string.h>

int main()
{
int i;
char str[50];
cout<<"Enter a String: ";
cin.getline(str,50);
for (i=0 ; str[i]!=NULL ; i++)
if(str[i]>='a' && str[i]<='z')
str[i]-=32;
else if(str[i]>='A' && str[i]<='Z')
str[i]=str[i]+32;
cout<<str;
_getch();
return 0;
}